标签:c style class blog code java
简单的排序,注意输出即可
#include <iostream> #include <algorithm> using namespace std; int main() { int a[10001]; int n,i; //int t = 0; while(cin>>n) { //if(t)cout<<endl; //t++; for(i=0; i<n; i++) { cin>>a[i]; } sort(a,a+n); if(n%2==1) { for(i=0; i<=(n-2)/2; i++) cout<<a[n-i-1]<<" "<<a[i]<<" "; cout<<a[i]; } else { for(i=0; i<=(n-2)/2; i++) { if(i==(n-1)/2) cout<<a[n-i-1]<<" "<<a[i]; else { cout<<a[n-i-1]<<" "<<a[i]<<" "; } } } cout<<endl; } return 0; }
hdu 1.3.4 shǎ崽 OrOrOrOrz,布布扣,bubuko.com
标签:c style class blog code java
原文地址:http://www.cnblogs.com/imLPT/p/3766715.html