c++20分求助!!希望大佬帮帮我
查看原帖
c++20分求助!!希望大佬帮帮我
849659
Aloteri楼主2023/3/21 21:13
#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;
}
2023/3/21 21:13
加载中...