-
题目描述:
-
对输入的n个数进行排序并输出。
-
输入:
-
输入的第一行包括一个整数n(1<=n<=100)。
接下来的一行包括n个整数。
-
输出:
-
可能有多组测试数据,对于每组数据,将排序后的n个整数输出,每个数后面都有一个空格。
每组测试数据的结果占一行。
-
样例输入:
-
4 1 4 3 2
-
样例输出:
-
1 2 3 4
#include<iostream> #include <stdio.h> #include <algorithm> using namespace std; int main() { int count,i; while (scanf("%d",&count) != EOF) { int *a=new int[count];
for (i=0;i<count;i++) { cin>>a[i]; } sort(a,a+count); for (i=0;i<count;i++) { cout<<a[i]<<" "; } cout<<"\n"; } return 0; }
开始的时候对于“有多组测试数据”的情况处理的不好,一直不AC