第20042题 单选题
C++生成对角线为1的n×n矩阵的横线代码应填入什么?

运行样例

请输入行列数量:9
1 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0
0 0 0 0 1 0 0 0 0
0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 1

代码片段

int N = 0;
cout << "请输入行列数量:";
cin >> N;
for (int i = 1; i < N + 1; i++) {
    for (int j = 1; j < N + 1; j++)
        if (________________) // 此处填写代码
            cout << 1 << " ";
        else
            cout << 0 << " ";
    cout << endl;
}
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析