2 solutions

  • 0
    @ 2024-12-15 16:07:26
    #include<bits/stdc++.h>
    using namespace std;
    int a[10][10];
    int main()
    {
        for(int i = 1;i <= 5;i++)
        {
            for(int j = 1;j <= 5;j++)
            {
                cin>>a[i][j];
            }
        }
        int r1,r2;
        cin>>r1>>r2;
        for(int i = 1;i <= 5;i++)
        {
            for(int j = 1;j <= 5;j++)
            {
                if(i == r1)
                {
                    int t = a[r1][j];
                    a[r1][j] = a[r2][j];
                    a[r2][j] = t;
                }
            }
        }
        for(int i = 1;i <= 5;i++)
        {
            for(int j = 1;j <= 5;j++)
            {
                cout<<a[i][j]<<" ";
            }
            cout<<endl;
        }
        return 0;
    }
    
    
    • -2
      @ 2024-12-8 9:17:24
      #include<bits/stdc++.h>
      using namespace std;
      int a[10][10];
      int main(){
          for(int i=1;i<=5;i++){
              for(int j=1;j<=5;j++){
                  cin>>a[i][j];
              }
          }
          int m,n,t;
          cin>>m>>n;
        
          for(int i=1;i<=5;i++){
              for(int j=1;j<=5;j++){
                  if(i==m){
                      int t=a[m][j];
                      a[m][j]=a[n][j];
                      a[n][j]=t;
                  }
              }
          }
          for(int i=1;i<=5;i++){
              for(int j=1;j<=5;j++){
                  cout<<a[i][j]<<" ";
              }
              cout<< endl;
          }
          return 0;
      }
    • 1

    Information

    ID
    903
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    1
    Tags
    (None)
    # Submissions
    96
    Accepted
    37
    Uploaded By