第25651题 判断题
判断将给定Python代码中print(0, end='')与if对齐后是否可实现预期对角矩阵输出

预期输出为n阶对角矩阵,对角线元素为1到n,其余元素均为0。 图片内容:n=9时的输出示例:9阶对角矩阵,对角线元素依次为1、2、…、9,其余位置均为0。

n = int(input("请输入矩阵大小n: "))
for i in range(n):
    for j in range(n):
        if i == j:
            print(i + 1, end='')
            continue
            print(0, end='')
    print()
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析