编辑代码

#include <iostream>
using namespace std;

//非递归
void IterativePrint(int n) {
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < i; j++) {
            cout << i << " ";
        }
        cout << endl;
    }
}

int main() {
    int n;
    cout << "请输入图案行数:";
    cin >> n;

    IterativePrint(n);

    return 0;
}