Advertisement
SergeyPGUTI

5.2.8

Oct 23rd, 2015
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <iostream>
  2.  using namespace std;
  3.  int main()
  4.  {
  5.      int a[100];
  6.      int n;
  7.      int temp;
  8.      cin>>n;
  9.      for (int i=0;i<n;i++)
  10.      {
  11.          cin>>a[i];
  12.      }
  13.  
  14.      for(int i=0;i<n-1;i+=2)
  15.      {
  16.          temp=a[i];
  17.          a[i]=a[i+1];
  18.          a[i+1]=temp;
  19.      }
  20.  
  21.      for (int i=0;i<n;i++)
  22.      {
  23.          cout<<a[i]<<" ";
  24.      }
  25.  
  26.  return 0;
  27.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement