为啥为啥啊,大哥哥们,6过不了,呜呜呜呜
查看原帖
为啥为啥啊,大哥哥们,6过不了,呜呜呜呜
441146
爷傲奈我何pro楼主2021/1/10 15:20
#include<bits/stdc++.h>
using namespace std;
struct student
{
  char name[50];
  int a;
  int b;
  int c;
}stu[105];
int cmp(student x,student y){ 
    if(x.a!=y.a) return x.a<=y.a;     
    else{
      if(x.b!=y.b) return x.b<=y.b; 
      else if(x.c!=y.c) return x.c<=y.c;
      else return x.name > y.name;
    }
}
int main(){
  int n;
  cin>>n;
  for (int i = 0; i < n; i++)
    scanf("%s %d %d %d",stu[i].name,&stu[i].a,&stu[i].b,&stu[i].c);
  stable_sort(stu,stu+n,cmp);
  for (int i = 0; i < n; i++)
    printf("%s\n",stu[i].name);
}
2021/1/10 15:20
加载中...