You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
#include<bits/stdc++.h>
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
//ѧ<><D1A7><EFBFBD>Ľṹ<C4BD><E1B9B9>
|
|
|
|
|
typedef struct student {
|
|
|
|
|
char name[20];
|
|
|
|
|
int math;
|
|
|
|
|
int english;
|
|
|
|
|
} Student;
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
bool cmp(Student a,Student b);
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
//<2F>Ȱ<EFBFBD>math<74>Ӵ<EFBFBD><D3B4><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>math<74><68><EFBFBD>ȣ<EFBFBD><C8A3><EFBFBD>english<73>Ӵ<EFBFBD><D3B4><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>
|
|
|
|
|
Student a[4]= {{"xiaoming",67,89},{"limei",90,56},{"zhaosi",90,99}};
|
|
|
|
|
sort(a,a+3,cmp);
|
|
|
|
|
for(int i=0; i<3; i++)
|
|
|
|
|
cout<<a[i].name <<" "<<a[i].math <<" "<<a[i].english <<endl;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5>
|
|
|
|
|
bool cmp(Student a,Student b) {
|
|
|
|
|
if(a.math <b.math )
|
|
|
|
|
return a.math <b.math ;//<2F><>math<74>Ӵ<EFBFBD><D3B4><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>
|
|
|
|
|
else if(a.math ==b.math )
|
|
|
|
|
return a.english>b.english ; //math<74><68><EFBFBD>ȣ<EFBFBD><C8A3><EFBFBD>endlish<73>Ӵ<EFBFBD><D3B4><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>23
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|