#include<cstdio>#include<algorithm>#include<stdlib.h>#include<cstring>using namespace std;struct student{ int id; char name[10]; int grade;}st[100010];int c;bool cmp(student x,student y){ if(c==1) return x.id<y.id; else if(c==2) { if(strcmp(x.name,y.name)!=0) return strcmp(x.name,y.name)<0; else return x.id<y.id; } else if(c==3) { if(x.grade!=y.grade) return x.grade<y.grade; else return x.id<y.id; }}int main(){ int n; scanf("%d%d",&n,&c); for(int i=0;i<n;i++) { scanf("%d %s %d",&st[i].id,st[i].name,&st[i].grade); } sort(st,st+n,cmp); for(int i=0;i<n;i++) { PRintf("%06d %s %d/n",st[i].id,st[i].name,st[i].grade); } system("pause"); return 0;}
新闻热点
疑难解答