#GESP3174. [GESP]L2-202506-Q3174-S

[GESP]L2-202506-Q3174-S

下面 C++ 代码实现输出如下图形,相关说法错误的是( )。

0
12
345
6789
01234
567890
1234567
89012345
678901234
5678901234
int line_number, now_number;
int i, row;

cout << "请输入行数:";
cin >> line_number;
now_number = 0;

for (row = 1; row < line_number + 1; row++) { // L1
    for (i = 0; i < row; i++) { // L2
        cout << now_number;
        now_number += 1;
        if (now_number == 10) now_number = 0; // L3
    }
    cout << endl;
}

{{ select(1) }}

  • 代码 now_number = 0 移动到 L1 和 L2 标记的两行代码之间,效果维持不变
  • 代码 now_number += 1 修改为 now_number = 1 + now_number 效果维持不变
  • 将代码 now_number == 10 调整为 now_number > 9 效果维持不变
  • 将最后一行的 cout << endl 修改为 cout << "\n",效果维持不变