编辑代码

#include <stdio.h>

void printPatternIterative(int n) {
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < i; j++)
            printf("%d ", i);

        printf("\n");
    }
}

int main() {
    int n;
    printf("请输入一个正整数:");
    scanf("%d", &n);

    printPatternIterative(n);

    return 0;
}