标签:des blog io os sp for 数据 div log
6 1 2 3 4 5 6
1 6 3 4 5 2
#include <iostream> #include <string> #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; int cmp(int a, int b) { return a>b; } int main() { unsigned int n; int a[100], e=0; int b[100], d=0; int i, j; cin>>n; int dd; for(i=1; i<=n; i++) { cin>>dd; if(i%2==1) a[e++]=dd; else b[d++]=dd; } sort(a, a+e); sort(b, b+d, cmp); if(n%2==0) { for(i=0; i<(n/2); i++) { if(i==0) cout<<a[i]<<" "<<b[i]; else cout<<" "<<a[i]<<" "<<b[i]; } cout<<endl; } else { for(i=0; i<(n/2); i++) { cout<<a[i]<<" "<<b[i]<<" "; } cout<<a[e-1]<<endl; } return 0; }
标签:des blog io os sp for 数据 div log
原文地址:http://www.cnblogs.com/yspworld/p/4109286.html