【DG特长生2017 T1】【SSL 2874】优美景点

优美景点

题目链接:SSL 2874

题目大意

有一些数,要你把它们排序从大到小输出。

思路

直接 sort。

代码

#include<cstdio>
#include<algorithm>

using namespace std;

int n, a[1001];

bool cmp(int x, int y) {
    
    
	return x > y;
}

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]);
	
	fclose(stdin);
	fclose(stdout);
	
	return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_43346722/article/details/115414436