Description
现在有不定组数的整型数据,
对于每组数据,先给出该组数据的个数n,然后是n个整数。要求对每组数进行排序,然后从小到大输出,中间用英文逗号分隔。
Input
不定行数的数据,每行第一个数为该组数据的个数n,然后是n个整数。
Output
输出对应行数的数据,为每组数排序后的,从小到大输出,中间用英文逗号分隔。
Sample Input
3 2 4 1
5 40 9 4 34 5
Sample Output
1,2,4
4,5,9,34,40
//数据排序
#include <stdio.h>
int main()
{
int a[1005],n,t;
while(~scanf("%d",&n))
{
for(int i=0; i<n; i++)
{
scanf("%d",&a[i]);
}
for(int i=0; i<=n; i++)
{
for(int j=0; j<=n; j++)
{
if(a[j]>a[j+1])
{
t=a[j];
a[j]=a[j+1];
a[j+1]=t;
}
}
}
for(int i=0; i<n-1; i++)
{
printf("%d,",a[i]);
}
printf("%d\n",a[n-1]);
}
return 0;
}