1 条题解

  • 0
    @ 2024-11-3 15:30:36
    #include <iostream>
    using namespace std;
    int a[105][105],h,k=1,l,hy=0;
    int main(){
        int n;
        cin >> n;
        hy = n-1;
        for(int i = 1;i<=n;i++) {
            h = n-hy;
            l = 1;
            for (; h != 0;) {
                a[h][l] = k++;
                h--;
                l++;
            }
            hy--;
        }
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                if (a[i][j] == 0){
                    continue;
                }else {
                    printf("%d ", a[i][j]);
                }
            }
            cout << "\n";
        }
    }
    

    (this is 博客on 白的码)

    信息

    ID
    298
    时间
    1000ms
    内存
    64MiB
    难度
    10
    标签
    递交数
    6
    已通过
    2
    上传者