http://ac.jobdu.com/problem.php?cid=1040&pid=0
-
题目描述:
-
对输入的n个数进行排序并输出。
-
输入:
-
输入的第一行包括一个整数n(1<=n<=100)。
接下来的一行包括n个整数。
-
输出:
-
可能有多组测试数据,对于每组数据,将排序后的n个整数输出,每个数后面都有一个空格。
每组测试数据的结果占一行。
-
样例输入:
-
4 1 4 3 2
-
样例输出:
-
1 2 3 4
// 题目1:排序.cpp: 主项目文件。
//#include "stdafx.h"
#include <cstdio>
#include <algorithm>
using namespace std;
const int N=103;
int a[N];
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i=0;i<n;i++)
scanf("%d",a+i);
sort(a,a+n);
for(int i=0;i<n;i++)
{
printf("%d ",a[i]);
}
printf("\n");
}
return 0;
}