第23080题 单选题
根据给定的C++数字三角打印代码及期望输出,判断下列说法正确的是

已知C++代码和执行后的期望输出如下,相关说法正确的是( )。

int i,j;
int last, N;

cout << "请输入层数N: ";
cin >> N;

last = 1;
for (i = 1; i < N; i++){
    for (j = 1; j < i + 1; j++){ // L1
        if (last > 9)
            last = 1;

        cout << last << " ";
        last += 1;
    }
    printf("\n");
}

当输入N=10时,期望输出为:

1
2 3
4 5 6
7 8 9 1
2 3 4 5 6
7 8 9 1 2 3
4 5 6 7 8 9 1
2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8 9
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析