90分求助!!第一个点RE vscode显示结构体“出现错误”
查看原帖
90分求助!!第一个点RE vscode显示结构体“出现错误”
1010751
lengty楼主2023/11/17 22:59
#include<bits/stdc++.h>
using namespace  std;
int n;

# 当输入样例一的时候会显示这里出错↓
struct student
{
    string name;
    int score;
    int chinese;
    int maths;
    int English;
}sst[1005];

bool cmp(student a,student b)
{
    return a.score<=b.score;
}

int main()
{
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        cin>>sst[i].name>>sst[i].chinese>>sst[i].maths>>sst[i].English;
        sst[i].score = sst[i].chinese+sst[i].maths+sst[i].English;
    }
    sort(sst,sst+n,cmp);
    cout<<sst[n-1].name<<" "<<sst[n-1].chinese<<" "<<sst[n-1].maths<<" "<<sst[n-1].English;
    system("pause");
    return 0;



}
2023/11/17 22:59
加载中...