Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4.    
  5.     int a,temp;
  6.     const int n = 2, m = 6;
  7.     int massiv[n][m]{ { 1,2,3,4,5,6 },{ 7,8,9,10,11,12 } };
  8.     cout << "На сколько шагов сдвиг влево? ";
  9.     cin >> a;
  10.     for (int i = 0; i < a; i++) {
  11.         for (int j = 0; j < n; j++) {
  12.             temp = massiv[j][0];
  13.             for (int g = 0; g < m-1; g++)
  14.                 massiv[j][g] = massiv[j][g+1];
  15.             massiv[j][m - 1] = temp;
  16.         }
  17.     }
  18.     for (int i = 0; i < n; i++) {
  19.         for (int j = 0; j < m; j++)
  20.             cout << massiv[i][j] << " ";
  21.         cout << endl;
  22.     }
  23.  
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement