文章
17
粉丝
0
获赞
119
访问
4.3k
#include <bits/stdc++.h>
using namespace std;
struct stu{
string name;
int num;
};
bool cg(const stu& a,const stu& b){
return a.num>b.num;
}
bool cl(const stu& a,const stu& b){
return a.num<b.num;
}
int main() {
int n,way;
while(cin>>n){
cin>>way;
vector<stu> m(n);
for(int i =0;i<n;i++) cin>>m[i].name>>m[i].num;
if(way==0) stable_sort(m.begin(),m.end(),cg);
else stable_sort(m.begin(),m.end(),cl);
for(int i =0;i<n;i++) cout...
登录后发布评论
暂无评论,来抢沙发