编辑代码

public class NumberTriangleNonRecursive {

    public static void main(String[] args) {
        int n = 5;
        printNumberTriangleNonRecursive(n);
    }

    public static void printNumberTriangleNonRecursive(int n) {
        for (int i = 1; i <= n; i++) {
            printNumbers(i, i);
            System.out.println();
        }
    }

    public static void printNumbers(int number, int count) {
        for (int i = 0; i < count; i++) {
            System.out.print(number + " ");
        }
    }
}