Advertisement
Haval1

Answer quastion 4

May 23rd, 2018
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int a[4][4],i,j,b[4];
  6.     for(i=0;i<4;i++)
  7.     {
  8.         for(j=0;j<4;j++)
  9.         {
  10.             cout<<"["<<i<<"]["<<j<<"]";
  11.             cin>>a[i][j];
  12.         }
  13.     }
  14.     cout<<"\nBefore rotate secondary diameter\n";
  15.     for(i=0;i<4;i++)
  16.     {
  17.         for(j=0;j<4;j++)
  18.         {
  19.             cout<<a[i][j]<<"\t";
  20.         }
  21.         cout<<endl<<endl;
  22.     }
  23.     cout<<endl;
  24.     for(i=0;i<4;i++)
  25.     {
  26.         b[i]=a[i][3-i];
  27.     }
  28.     for(j=1;j<=5;j++)
  29.     {
  30.         b[4]=b[0];
  31.         for(i=0;i<4;i++)
  32.         {
  33.             b[i]=b[i+1];
  34.         }
  35.     }
  36.     for(i=0;i<4;i++)
  37.     {
  38.         cout<<b[i]<<"\t";
  39.     }
  40.     for(i=0;i<4;i++)
  41.     {
  42.         a[i][3-i]=b[i];
  43.     }
  44.     cout<<"\nAfter rotate secondary diameter\n";
  45.     for(i=0;i<4;i++)
  46.     {
  47.         for(j=0;j<4;j++)
  48.         {
  49.             cout<<a[i][j]<<"\t";
  50.         }
  51.         cout<<endl<<endl;
  52.     }
  53.    
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement