#include <iostream> #include <string> using namespace std; struct Student{ string name; int c1, c2, c3; int total; }; int main() { int N; cin >> N; // 注意 while 处理多个 case Student student [1000]; int max_total = -1; int index = 0; for(int i = 0; i < N; i++){ cin >> student[i].name >> student[i].c1 >> student[i].c2 >> student[i].c3; student[i].total = student[i].c1 + student[i].c2 +student[i].c3; if(student[i].total > max_total){ max_total = student[i].total; index = i; } } cout << student[index].name << " " << student[index].c1 << " " << student[index].c2 << " " << student[index].c3 << endl; return 0; } // 64 位输出请用 printf("%lld")
注意 空格和注意struct格式