1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <algorithm> 4 using namespace std; 5 struct E{ 6 char name[101]; 7 int age; 8 int score; 9 }buf[1000]; 10 bool cmp(E a, E b){ 11 if(a.score != b.score) return a.score < b.score; 12 13 int tmp = strcmp(a.name ,b.name); 14 if(tmp != 0) return tmp < 0; 15 else return a.age < b.age; 16 } 17 int main(){ 18 int n; 19 int i; 20 while(scanf("%d",&n) != EOF){ 21 for(i = 0;i < n;i++){ 22 scanf("%s%d%d",buf[i].name,&buf[i].age,&buf[i].score); 23 } 24 sort(buf,buf+n,cmp); 25 for(i = 0;i < n;i++){ 26 printf("%s %d %d\n",buf[i].name,buf[i].age,buf[i].score); 27 } 28 } 29 system("pause"); 30 return 0; 31 }
时间: 2024-11-05 14:56:47