MaksNew

Untitled

Dec 14th, 2020
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4. int main()
  5. {
  6.     setlocale(LC_ALL, "Russian");
  7.     int k, n, temp;
  8.     cout << "Введите размер массива:" << endl;
  9.     cin >> k;
  10.     int* a = new int[k];
  11.  
  12.     cout << "Введите элементы:" << endl;
  13.     for (int i = 0; i < k; i++)
  14.     {
  15.         cin >> a[i];
  16.     }
  17.  
  18.     cout << "На сколько позиций двигать:" << endl;
  19.     cin >> n;
  20.  
  21.     for (int i = 0; i < n; ++i)
  22.     {
  23.         temp = a[k-1];
  24.         for (int j = k - 2; j >= 0; --j)
  25.         {
  26.             a[j + 1] = a[j];
  27.         }
  28.         a[0] = temp;
  29.     }
  30.  
  31.     for (int i = 0; i < k; i++)
  32.     {
  33.         cout << "Result " << a[i] << endl;
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment