标签:des style blog io color ar os java sp
3 1 000007 James 85 000010 Amy 90 000001 Zoe 60 4 2 000007 James 85 000010 Amy 90 000001 Zoe 60 000002 James 98 4 3 000007 James 85 000010 Amy 90 000001 Zoe 60 000002 James 90 0 0
Case 1: 000001 Zoe 60 000007 James 85 000010 Amy 90 Case 2: 000010 Amy 90 000002 James 98 000007 James 85 000001 Zoe 60 Case 3: 000001 Zoe 60 000007 James 85 000002 James 90 000010 Amy 90#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; struct st { int xh; char name[15]; int f; }data[110000]; int cmp(st a,st b) { return a.xh<b.xh; } int asd(st a,st b) { if(!strcmp(a.name,b.name)) return a.xh<b.xh; else return strcmp(a.name,b.name)<0; } int ans(st a,st b) { if(a.f!=b.f) return a.f<b.f; else return a.xh<b.xh; } int main() { int i,n,c,k=1;; while(scanf("%d %d",&n,&c)&&n!=0) { for(i=1;i<=n;i++) scanf("%d %s %d",&data[i].xh,data[i].name,&data[i].f); if(c==1) sort(data+1,data+n+1,cmp); if(c==2) sort(data+1,data+n+1,asd); if(c==3) sort(data+1,data+n+1,ans); printf("Case %d:\n",k); for(i=1;i<=n;i++) { printf("%06d %s %d\n",data[i].xh,data[i].name,data[i].f); } k++; } return 0; }
标签:des style blog io color ar os java sp
原文地址:http://blog.csdn.net/hdd871532887/article/details/40922315