解题思路:
这题我就是用cmp从大到小排序后输出前10个。
大家也可以先sort从小到大排序后输出后10个,不过有些费脑去找坐标。
我觉得打个bool也不多,不费时间,好一点。
注意事项:
无。
参考代码:
#include<bits/stdc++.h>
using namespace std;
int n,a[555];
bool cmp(int x,int y){
return x>y;
}
int main(){
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<=10;i++)
printf("%d ",a[i]);
printf("\n");
return 0;
}
0.0分
0 人评分