Sursur @ 2024-12-01 00:23:34
#include <bits/stdc++.h>
using namespace std;
struct student{
string name;
int a[3];
};
int main(){
int n;
cin>>n;
student s[n];
for(int i=0;i<n;i++){
cin>>s[i].name;
for(int j=0;j<3;j++){
cin>>s[i].a[j];
}
}
int b[n]={0};
for(int i=0;i<n;i++){
for(int j=0;j<3;j++){
b[i]+=s[i].a[j];
}
}
int d=0;
for(int i=0;i<n;i++){
if(b[i]>d){
d=b[i];
}
}
int e;
for(int i=0;i<n;i++){
if(b[i]==d){
e=i;
}
}
cout<<s[e].name<<' ';
for(int i=0;i<3;i++){
cout<<s[e].a[i]<<' ';
}
}
by wujunxi206 @ 2024-12-01 07:36:05
@Sursur 求关QAQ
#include <iostream>
#include <vector>
#include <string>
using namespace std;
struct Student {
string name;
int scores[3];
int totalScore;
};
int main() {
int n;
cin >> n;
vector<Student> students(n);
int maxTotalScore = 0;
int maxScoreIndex = 0;
for (int i = 0; i < n; i++) {
cin >> students[i].name;
students[i].totalScore = 0;
for (int j = 0; j < 3; j++) {
cin >> students[i].scores[j];
students[i].totalScore += students[i].scores[j];
}
if (students[i].totalScore > maxTotalScore) {
maxTotalScore = students[i].totalScore;
maxScoreIndex = i;
}
}
cout << students[maxScoreIndex].name << ' ';
for (int i = 0; i < 3; i++) {
cout << students[maxScoreIndex].scores[i] << ' ';
}
cout << endl;
return 0;
}
by Sursur @ 2024-12-01 22:09:04
@wujunxi206感谢大佬
by CZY130310 @ 2024-12-15 19:53:37
帅哥!
by yaoym @ 2024-12-15 19:56:30
@CZY130310 @CZY130310 @CZY130310 @CZY130310 @CZY130310