Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- void function(vector<int>& arr, int i, int k)
- {
- if (i == k - 1 || i == k)
- {
- swap(arr[i], arr[k]);
- }
- else
- {
- swap(arr[i], arr[k]);
- function(arr, i + 1, k - 1);
- }
- }
- int main()
- {
- int n;
- cin >> n;
- vector<int> arr;
- for (int i = 0; i < n; i++) //ввод
- {
- int a;
- cin >> a;
- arr.push_back(a);
- }
- function(arr, 0, n - 1); //массив перевернут
- for (int i = 0; i < n; i++) //вывод
- cout << arr[i] << " ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement