简单的排序,注意输出即可 

#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;
}