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