#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
1.
// 没有sort没有cmp时本身默认是从小到大,所以这个地方写了一个从大到下的cmp
bool cmp(char a,char b){
参数类型看情况写
return a>b; //可以理解为 a > b 时把a放在b前面
}
using namespace std;
int main(){
//char c[] = {'a', 'n', 'c', 'd'};
char c[] = {
'T', 'W', 'A', 'K'};
sort(c, c + 4,cmp);
for(int i = 0; i < 4; i++){
printf("%c",c[i]);
}
system("pause");
return 0;
}
*/
struct Student{
char id[15]; //准考证号
int score; //分数
int location_number; //考场号
int local_rank; //考场内排名
}stu[30010];
bool cmp(Student a, Student b){
if(a.score != b.score) return a.score > b.score; //先按分数从高到底排序
else return a.id < b.id;
}
int main(){
int n,k,num=0; //num 为总考生数
scanf("%d",&n); //n为考场数
for
c语言练习篇(5)
最新推荐文章于 2024-08-14 18:20:25 发布