The students are so excited—they can finally go on an autumn outing! The teacher says that it's a bit dangerous to go alone, so let's pair up and travel together. The pairing rule is as follows: the first person in line pairs up with the last person, the second person pairs up with the second-to-last person, and so on, forming pairs of two. Now, let's quickly organize! As soon as the teacher finishes speaking, the students pair up swiftly, ready to set off!
Input Format:
The first line is an integer n, representing the number of students. (2<=n<=50,and n is even).
The second line contains n integers representing the student numbers, separated by spaces.
Output Format:
There are n/2 lines, each containing two integers representing the paired student numbers, separated by a space.
Sample Input:
6
5 6 4 12 3 2
Sample Output:
5 2
6 3
4 12
代码如下:
#include<iostream>
#include<vector>
using namespace std;
int main()
{
int n;
cin>>n;
vector<int> a(n);
for(int i=0;i<n;i++)
{
cin>>a[i];
}
for(int j=0;j<n/2;j++)
{
cout<<a[j]<<" "<<a[n-j-1]<<endl;
}
return 0;
}