c++20分求助!!希望大佬帮帮我

P5740 【深基7.例9】最厉害的学生

Aloteri @ 2023-03-21 21:13:20

#include<iostream>
#include<string>
using namespace std;

struct Student
{   
    string m_Name;
    int c, m, e ,score=c+m+e;

}stu[1000];
int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> stu[i].m_Name >> stu[i].c >> stu[i].m >> stu[i].e;
    }

    int max = stu[0].score, maxIndex = 0;
    for (int i = 0; i < n; i++)
    {
        if (stu[i].score > max) {
            maxIndex = i;
        }
    }
    cout << stu[maxIndex].m_Name <<" " << stu[maxIndex].c <<" " << stu[maxIndex].m <<" "<< stu[maxIndex].e << endl;
    return 0;
}

by Geirangerfjard @ 2023-03-21 21:36:52

@HY248 %%蓝勾巨佬


by Geirangerfjard @ 2023-03-21 21:37:38

@Aloteri 不客气的,最后加油吧,oi这条路不好走的


by Aloteri @ 2023-03-21 21:39:09

@HY248 感谢您的指导!


上一页 |