Advertisement
Kristina_Bahtina

22.11.17 задача 11г

Nov 22nd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. # include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5.  
  6. {
  7.     const int n = 6;
  8.     int a[n];
  9.     int i;
  10.     cout << "enter vector" << endl;
  11.     for (i = 0; i<n; i++)
  12.     {
  13.         cin >> a[i];
  14.     }
  15.  
  16.     cout << "vector a" << endl;
  17.     for (i = 0; i<n; i++)
  18.         cout << a[i] << " ";
  19.     cout << endl;
  20.  
  21.    
  22.     for(i = 0; i<n-1; i++)
  23.     {
  24.         if ((i%2)!=0)
  25.         swap(a[i],a[i+1]);
  26.     }
  27.      swap(a[0],a[n-1]);
  28.     cout << "vector y" << endl;
  29.     for (i = 0; i<n; i++)
  30.         cout << a[i] << " ";
  31.     cout << endl;
  32.    
  33.     system("pause");
  34.  
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement