Problem Descriptionacmer in HDU-ACM team is ambitious, especially shǎ cub, he can spend time in Internet bar doing problems Overnight. So many girls want to meet and Orz him. But Orz him are not so easy. You must solve this problem first. The problem is:give you a sequence of distinct integers, choose numbers as Following:first choose the biggest and then SM Allest, then second biggest, second smallest etc. Until all the numbers was chosen. For example, give your 1 2 3 4 5, you should output 5 1 4 2 3 inputthere is multiple test cases, each case begins with one Integer n (1 <= n <= 10000), following n distinct integers. Outputoutput a sequence of distinct integers described above. Sample INPUT5 1 2 3 4 5 Sample OUTPUT5 1 4 2 3//flood problem. But pay attention to the format
1#include <iostream>2#include <cstdio>3#include <algorithm>4 5 using namespacestd;6 7 intMain ()8 {9 intn,i;Ten intdata[10005]; One while(cin>>N) A { - for(i=1; i<=n;i++) -scanf"%d",&data[i]); theSort (data+1, data+1+n); - if(n%2==0)//an even number of 4/2=2 4 1 3 2 - { - for(i=n;i>n/2+1; i--) +cout<<data[i]<<" "<<data[n-i+1]<<" "; -cout<<data[i]<<" "<<data[n-i+1]<<endl;//otherwise PE + } A Else//There are odd numbers of 5/2=2 5 1 4 2 3 at { - for(i=n;i>n/2+1; i--) -cout<<data[i]<<" "<<data[n-i+1]<<" "; -cout<<data[n/2+1]<<Endl; - } - in - } to return 0; +}
Hdu2673:shǎ Cub Ororororz