文章

1

粉丝

136

获赞

0

访问

3.5k

头像
求解错在哪 一直66%
P1151 清华大学上机题
发布于2023年1月24日 19:14
阅读数 3.5k

#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...

登录查看完整内容


登录后发布评论

1 条评论
快乐小土狗
2023年1月24日 20:08

输入描述里有提示,多组测试数据输入,需要加while

赞(3)