hdu-2673-shǎ崽 OrOrOrOrz(水题)
注意输出格式
1 #include <iostream> 2 #include <algorithm> 3 using namespace std; 4 int arr[10000+9]; 5 int main() { 6 int n; 7 while (cin>>n) { 8 for (int i=0; i<n; i++) cin>>arr[i]; 9 sort(arr, arr+n); 10 cout<<arr[n-1]; 11 for (int i=0; i*2<n-1; i++) { 12 if (n-i-2 == i){ 13 cout<<" "<<arr[i]; 14 continue; 15 } 16 cout<<" "<<arr[i]<<" "<<arr[n-i-2]; 17 } 18 cout<<endl; 19 } 20 return 0; 21 }