sun_fl0wer @ 2022-08-19 20:57:46
#include<bits/stdc++.h>
using namespace std;
struct stu {
string name;
int chi;
int mat;
int eng;
int tot;
} students[10010];
int main(void) {
int n;
int score = -1;
int t = 0;
stu* p = students;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%s%d%d%d", &((p + i)->name), &((p + i)->chi), &((p + i)->mat), &((p + i)->eng));
(p + i)->tot = (p + i)->chi + (p + i)->mat + (p + i)->eng;
if ((p + i)->tot > score) {
score = (p + i)->tot;
t = i;
}
}
printf("%s %d %d %d\n", (p + t)->name, (p + t)->chi, (p + t)->mat, (p + t)->eng);
return 0;
}
by CarDriveer @ 2022-08-19 21:02:15
输出string
类型不能用printf
语句要用cout
by CarDriveer @ 2022-08-19 21:03:32
@sun_fl0wer
by sun_fl0wer @ 2022-08-19 21:04:51
@AB_chen 学到了,谢谢大佬!!
by CarDriveer @ 2022-08-19 21:06:16
@sun_fl0wer 还有输入也要改成cin
by Fkxxx @ 2022-08-20 20:06:29
using namespace std;
都用了干嘛不用cin,cout