Advertisement
Guest User

Untitled

a guest
Nov 25th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <cstdlib>
  2. #include <ctime>
  3. #include <iostream>
  4. #define M 3
  5. #define N 3
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     srand(time(NULL));
  12.     int tab[M][N];
  13.  
  14.  
  15.     for(int i=0; i<M; i++)
  16.     {
  17.         for(int j=0; j<N; j++)
  18.         {
  19.             tab[i][j]=rand()%10-5;
  20.         }
  21.     }
  22.  
  23.     for(int i=0; i<M; i++)
  24.     {
  25.         for(int j=0; j<N; j++)
  26.         {
  27.             cout<<tab[i][j]<<" ";
  28.         }
  29.         cout<<endl;
  30.     }
  31.     cout<<endl<<endl;
  32.  
  33.     int pom;
  34.     for(int i=0; i<M; i++)
  35.     {
  36.         for(int j=0; j<N; j++)
  37.         {
  38.             pom=tab[i][j];
  39.             tab[i][j]=tab[M-i-1][N-j-1];
  40.             tab[M-i-1][N-j-1]=pom;
  41.         }
  42.     }
  43.  
  44.     for(int i=0; i<M; i++)
  45.     {
  46.         for(int j=0; j<N; j++)
  47.         {
  48.             cout<<tab[i][j]<<" ";
  49.         }
  50.         cout<<endl;
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement