编辑代码

public class NonRecursivePattern {

    // 非递归函数
    public static void printNonRecursive(int n) {
        for (int i = 1; i <= n; i++) {
            for (int j = 0; j < i; j++) {
                System.out.print(i + " "); // 打印当前i的值i次
            }
            System.out.println(); // 换行
        }
    }

    public static void main(String[] args) {
        int n = 5; // 假设n的值为5
        printNonRecursive(n); // 调用非递归函数输出
    }
}