文章
1
粉丝
136
获赞
0
访问
3.9k
#include<bits/stdc++.h>
using namespace std;
typedef struct
{
string name;
int score;
}student;
bool compare0(student a,student b)//降序
{
return a.score>b.score;
}
bool compare1(student a,student b)//升序
{
return a.score<b.score;
}
int main()
{
int num,a,i,n;
cin>>num;
cin>>a;
student stu[num];
for(i=0;i<num;i++)
{
student s;
cin>>s.name>>s.score;
stu[i]=s;
}
if(a==0)
{
stable_sort(stu,stu+num,compare0);
}
else if(a==1)
{
&nb...
登录后发布评论
输入描述里有提示,多组测试数据输入,需要加while