Description
There are n (2<=n<=50) integers. Arrange them in a row so that the maximal difference between adjacent numbers is minimal.
Input
The first line contains one integer, indicating the number of test cases. For each test case, there is one line containing the n numbers.
Output
Output one line for each test case containing an arrangement of the numbers which minimizes the maximal difference. Numbers should be separated by one space. If there are several arrangements that meet the requirement, output the lexicographically smallest one.
Sample Input
2
5 1 3
1 8 2 4
Sample Output
1 3 5
1 2 4 8
¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥
要注意结束以‘\n’,注意和字符的交配使用;
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int g[100000];
int i,j,k,ncase,m,n;
scanf("%d",&ncase);
while(ncase--)
{
char c;i=0;
while(scanf("%d%c",&g[i++],&c)!=EOF)
{
if(c=='\n')
break;
}
sort(g,g+i);
printf("%d",g[0]);
for(j=1;j<i;j++)
printf(" %d",g[j]);
printf("\n");
}
return 0;
}