#include<stdio.h> #include<algorithm> #include<cstring> using namespace std; struct student{ char name[20]; int height; int money; }; bool cmp(student a,student b){ return a.height>b.height; } bool cmp2(student a,student b){ return a.money>b.money; } int main(){ int n; scanf("%d",&n); getchar(); student s[n],s2[n]; int i; for(i=0;i<n;i++){ scanf("%s %d %d",s[i].name,&s[i].height,&s[i].money); strcpy(s2[i].name,s[i].name); s2[i].height=s[i].height; s2[i].money=s[i].money; } sort(s,s+n,cmp); sort(s2,s2+n,cmp2); for(i=0;i<n;i++){ printf("%s %d %d\n",s[i].name,s[i].height,s[i].money); } for(i=0;i<n;i++){ printf("%s %d %d\n",s2[i].name,s2[i].height,s2[i].money); } // int a,b; // for(i=0;i<n;i++){ // if(s[i].name=="Suxiao"){ // a=i; // } // } // for(i=0;i<n;i++){ // if(s2[i].name=="Suxiao"){ // b=i; // } // } // if(a>b){ // printf("HEIGHT\n"); // } // else if(a<b){ // printf("MONET\n"); // // } // else{ // printf("EQ\n"); // } // return 0; } |
Double click to view unformatted code.