sicily 1688 Soldiers

来源:互联网 发布:中国十大域名注册商 编辑:程序博客网 时间:2024/05/21 07:53
// Problem#: 1688// Submission#: 1657719// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/// All Copyright reserved by Informatic Lab of Sun Yat-sen University#include <iostream>#include <algorithm>#include <cstdio>using namespace std;int main(){    int test;    cin >> test;    while (test--)    {        int n,arr[10005];        scanf ("%d",&n);        for (int i = 0; i < n; i++)            scanf ("%d",&arr[i]);        sort(arr,arr+n);                int head = 0;        int rear = n - 1;        for (int j = 0; j <= n/2; j++)        {            printf ("%d ",arr[head]);            head++;            if (rear > head)            {                printf ("%d ",arr[rear]);            }            rear--;        }        printf ("\n");    }    return 0;}                                 

原创粉丝点击