标签:
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 14483 Accepted Submission(s): 5597
#include<stdio.h> #include<string.h> #include<algorithm> #define MAX 100010 using namespace std; struct record { int hao; char a[10]; char s[10]; int score; }num[MAX]; bool cmp1(record a,record b) { return a.hao<b.hao; } bool cmp2(record c,record d) { if(strcmp(c.s,d.s)!=0) return strcmp(c.s,d.s)<0; else return c.hao<d.hao; } bool cmp3(record e,record f) { if(e.score!=f.score) return e.score<f.score; else return e.hao<f.hao; } int main() { int n,m,j,i,s,t,l; l=1; while(scanf("%d%d",&n,&m)&&n!=0&&m!=0) { for(i=0;i<n;i++) { num[i].hao=0; } for(i=0;i<n;i++) { scanf("%s%s%d",&num[i].a,&num[i].s,&num[i].score); for(j=0;j<6;j++) { num[i].hao=num[i].hao*10+(num[i].a[j]-‘0‘); } } if(m==1) { sort(num,num+n,cmp1); printf("Case %d:\n",l); for(i=0;i<n;i++) { printf("%s %s %d\n",num[i].a,num[i].s,num[i].score); } } else if(m==2) { sort(num,num+n,cmp2); printf("Case %d:\n",l); for(i=0;i<n;i++) { printf("%s %s %d\n",num[i].a,num[i].s,num[i].score); } } else if(m==3) { sort(num,num+n,cmp3); printf("Case %d:\n",l); for(i=0;i<n;i++) { printf("%s %s %d\n",num[i].a,num[i].s,num[i].score); } } l++; } return 0; }
标签:
原文地址:http://www.cnblogs.com/tonghao/p/4668295.html