alternately alternative sort of array sorted array

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 
 4 const int maxn=10005;
 5 
 6 int main()
 7 {
 8     int t;
 9     cin>>t;
10     while(t--)
11     {
12         int n;
13         int a[maxn];
14         cin>>n;
15         for(int i=0;i<n;i++)
16         {
 . 17              CIN >> A [I];
 18 is          }
 . 19          Sort (A, A + n-);
 20 is          int head = 0 ;
 21 is          int tail = N- . 1 ;
 22 is          the while (head < tail) // index idea bis
 23          {
 24              << a COUT [tail -] << "  " ;
 25              COUT << [head ++] a << "  " ;
 26 is          }
 27          IF (n-% 2 ! = 0 ) // discussion of the nature of the individual processing
 28             cout<<a[head]<<endl;
29         else
30             cout<<endl;
31 
32     }
33     return 0;
34 }

 

Guess you like

Origin www.cnblogs.com/chuanwen-tech/p/11372013.html