Advertisement
xSiRON

ES2_21022017

Feb 21st, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int DIM = 4;
  5.  
  6. void printMatrix(long A[][DIM])
  7. {
  8.     for(int i = 0; i < DIM; i++)
  9.     {
  10.         for(int j = 0; j < DIM; j++){
  11.             cout << A[i][j] << " ";
  12.         }
  13.         cout << endl;
  14.     }
  15.     cout << "\n";
  16. }
  17.  
  18. void shifting(long A[][DIM])
  19. {
  20.     for(int i = DIM-1; i > 0; i--){
  21.         for(int j = 0; j < DIM; j++)
  22.         {
  23.             int tmp = A[i][j];
  24.             A[i][j] = A[i-1][j];
  25.             A[i-1][j] = tmp;
  26.         }
  27.     }
  28. }
  29. int main()
  30. {
  31.     long A[][DIM] = {{8, 7, 1, 4},
  32.                      {5, 6, 9, 3},
  33.                      {0, 1, 7, 6},
  34.                      {3, 3, 5, 8}};
  35.  
  36.     printMatrix(A);
  37.     shifting(A);
  38.     printMatrix(A);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement