文章
34
粉丝
89
获赞
2
访问
18.5k
#include<bits/stdc++.h> using namespace std; struct student{ string name; int grade; int seq; }; vector<student> vs; bool compare0(student lhs,student rhs){//降序 if(lhs.grade > rhs.grade) { return true; }else if(lhs.grade == rhs.grade){ return lhs.seq < rhs.seq; }else{ return false; } } bool compare1(student lhs,student rhs){//降序 if(lhs.grade < rhs.grade) { return true; }else if(lhs.grade == rhs.grade){ return lhs.seq < rhs.seq; }else{ return false; } } int main(){ int n,way; while(cin >> n >> way){ for(int i = 0;i < n;i++){ string name; int grade; int seq = i; cin >> name >> grade; student s = {name, grade, seq}; vs.push_back(s); } if(way==0){//降序 sort(vs.begin(),vs.end(), compare0); for...
登录后发布评论
暂无评论,来抢沙发