HNZZT @ 2023-11-17 20:25:45
#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string.h>
#include<map>;
using namespace std;
int main()
{
int n;
cin >> n;
getchar();
char a[1005][10];
int sum = 0;
int max = -1;
int p[1005][5];//存储成绩
map<string, int>mapA;
for (int i = 0;i < n;i++) {
cin.getline(a[i],10);//输入学生名字
for (int j = 0;j < 3;j++) {
cin >> p[i][j];
mapA[a[i]] += p[i][j];
}
if (mapA[a[i]] > max)max = mapA[a[i]];
getchar();
}
for (int i = 0;i < n;i++) {
if (mapA[a[i]] == max) {
cout << a[i] << " ";
for (int j = 0;j < 3;j++) {
cout << p[i][j] << " ";
}
break;
}
}
return 0;
}
by MichaelXucoutaendl @ 2023-11-17 20:43:56
getline
是读至行末,就吞掉了后面的数字