In a Line


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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值