1 条题解

  • 0
    @ 2024-9-24 21:37:51
    #include <iostream>
    #include <iomanip> // 包含 setw 函数的头文件
    
    using namespace std;
    
    int main() {
        int N;
        cin >> N; // 读取输入的整数 N
    
        // 遍历每一行
        for (int i = 1; i <= N; ++i) {
            // 遍历每一列
            for (int j = 1; j <= N; ++j) {
                // 根据行和列的索引确定要打印的数字
                int number = max(i, j);
                cout << setw(3) << number; // 设置输出宽度为 3
            }
            cout << endl; // 每行结束后换行
        }
    
        return 0;
    }
    
    
    • 1

    信息

    ID
    387
    时间
    1000ms
    内存
    16MiB
    难度
    6
    标签
    递交数
    23
    已通过
    13
    上传者