2 条题解

  • 3
    @ 2023-8-10 21:19:18

    编写不难 难在找规律

    已AC,放心食用

    #include <iostream>
    using namespace std;
    int main() {
        int n;
        cin >> n;
        int a[n][n];
        for (int i = 1;i <= n;++i){
            int x = n;
            int f = i;
            if (i == 1){
                for (int j = 1;j <= n;++j){
                    a[i][j] = f;
                    f += x;
                    x --;
                }
            }
            else{
                for (int j = 1;j <= i - 1;++j){
                    a[i][j] = a[j][i];
                }
                for (int j = i;j <= n;++j){
                    a[i][j] = f;
                    f += x;
                    x --;
                }
            }
        }
        for (int i = 1;i <= n;++i){
            for (int j = 1;j <= n;++j){
                if (a[i][j] / 10 > 0){
                    cout << "   " << a[i][j];
                }
                else{
                    cout << "    " << a[i][j];
                }
            }
            cout << endl;
        }
        return 0;
    }
    

    好像UI变了 注释写不上image

    • 0
      @ 2023-9-3 12:38:14

      #include <iostream> using namespace std; int main() { int n; cin >> n; int a[n][n]; for (int i = 1;i <= n;++i){ int x = n; int f = i; if (i == 1){ for (int j = 1;j <= n;++j){ a[i][j] = f; f += x; x --; } } else{ for (int j = 1;j <= i - 1;++j){ a[i][j] = a[j][i]; } for (int j = i;j <= n;++j){ a[i][j] = f; f += x; x --; } } } for (int i = 1;i <= n;++i){ for (int j = 1;j <= n;++j){ if (a[i][j] / 10 > 0){ cout << " " << a[i][j]; } else{ cout << " " << a[i][j]; } } cout << endl; } return 0; }

      • 1

      信息

      ID
      401
      时间
      1000ms
      内存
      16MiB
      难度
      3
      标签
      递交数
      37
      已通过
      23
      上传者