这一题总算是把C++的重载活学活用了一回,节省了很多脑细胞。
#includeusing namespace std;struct student{ string name; string code; int score; //operator < bool operator < (const student& b){ return this->score students;void solve(){ int n; cin>>n; while(n--){ student s; cin>>s.name>>s.code>>s.score; students.push_back(s); } sort(students.begin(),students.end()); cout< <<" "< <
sort一把梭,用vector存结构体,非常省事。