Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # include <iostream>
- using namespace std;
- int main()
- {
- const int n = 6;
- int a[n];
- int i;
- cout << "enter vector" << endl;
- for (i = 0; i<n; i++)
- {
- cin >> a[i];
- }
- cout << "vector a" << endl;
- for (i = 0; i<n; i++)
- cout << a[i] << " ";
- cout << endl;
- for(i = 0; i<n-1; i++)
- {
- if ((i%2)!=0)
- swap(a[i],a[i+1]);
- }
- swap(a[0],a[n-1]);
- cout << "vector y" << endl;
- for (i = 0; i<n; i++)
- cout << a[i] << " ";
- cout << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement