Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "Russian");
- int k, n, temp;
- cout << "Введите размер массива:" << endl;
- cin >> k;
- int* a = new int[k];
- cout << "Введите элементы:" << endl;
- for (int i = 0; i < k; i++)
- {
- cin >> a[i];
- }
- cout << "На сколько позиций двигать:" << endl;
- cin >> n;
- for (int i = 0; i < n; ++i)
- {
- temp = a[k-1];
- for (int j = k - 2; j != 0; --j)
- {
- a[j + 1] = a[j];
- }
- a[0] = temp;
- }
- for (int i = 0; i < k; i++)
- {
- cout << "Result " << a[i] << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment