2 条题解

  • 2
    @ 2023-4-13 19:21:10

    上一题的

    #include <iostream>
    using namespace std;
    int main()
    {
        int n;
        cin >> n;
        for(int i=1;i<=n;i++)
        {
            cout << " ";
            for(int j=1;j<=n;j++)
            {
                if((i-1)*n+j<10)
                {
                    cout << " ";
                }
                cout << (i-1)*n+j << " ";
            }
            cout << endl;
        }
    }
    

    这一题的

    #include <iostream>
    using namespace std;
    int main()
    {
        int n;
        cin >> n;
        for(int i=n;i>=1;i--)
        {
            cout << " ";
            for(int j=1;j<=n;j++)
            {
                if((i-1)*n+j<10)
                {
                    cout << " ";
                }
                cout << (i-1)*n+j << " ";
            }
            cout << endl;
        }
    }
    
    • 0
      @ 2023-4-9 15:12:17
      #include <iostream>
      using namespace std;
      int main()
      {
          int n;
          cin >> n;
          int x = n * n, a[n + 1][n + 1];
          for (int i = 1; i <= n; i++)
          {
              for (int j = 1; j <= n; j++)
              {
                  a[i][j] = x;
                  x--;
              }
          }
          for (int i = 1; i <= n; i++)
          {
              for (int j = 1; j <= n / 2; j++)
              {
                  swap(a[i][j], a[i][n - j + 1]);
              }
          }
          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
      185
      时间
      1000ms
      内存
      16MiB
      难度
      3
      标签
      递交数
      134
      已通过
      72
      上传者