题目描述
给出n个数,排序
样例输入
5
90
105
87
65
98
样例输出
105
98
90
87
65
思路
sort
代码
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int n, a[1005];
bool cmp(int a, int b)
{
return a > b;
}
int main()
{
//freopen("landscape.in", "r", stdin);
//freopen("landscape.out", "w", stdout);
scanf("%d", &n);
for(int i = 1; i <= n; ++i)
scanf("%d", &a[i]);
sort(a + 1, a + n + 1, cmp);
for(int i = 1; i <= n; ++i)
printf("%d\n", a[i]);
return 0;
fclose(stdin);
fclose(stdout);
}