A23题解
2026-09-27 14:57:07
发布于:广东
3阅读
0回复
0点赞
我们先定义一个结构体数组,然后判断是否满足条件,最后求最大值就可以了
代码:
#include <bits/stdc++.h>
using namespace std;
struct Student{
string name;
int score;
int score2;
char is_big;
char is_west;
int num;
int tot;
} students[105];
int main(){
ios::sync_with_stdio(0); cin.tie(0);
int t; cin >> t;
for (int i = 1; i <= t; i++){
cin >> students[i].name >> students[i].score >> students[i].score2 >> students[i].is_big >> students[i].is_west >> students[i].num;
students[i].tot = 0;
if (students[i].score > 80 && students[i].num > 0){
students[i].tot += 8000;
}
if (students[i].score > 85 && students[i].score2 > 80){
students[i].tot += 4000;
}
if (students[i].score > 90){
students[i].tot += 2000;
}
if (students[i].score > 85 && students[i].is_west == 'Y'){
students[i].tot += 1000;
}
if (students[i].score2 > 80 && students[i].is_big == 'Y'){
students[i].tot += 850;
}
}
int max_tot = -1;
string names;
int sum = 0;
for (int i = 1; i <= t; i++){
sum += students[i].tot;
if(students[i].tot > max_tot){
max_tot = students[i].tot;
names = students[i].name;
}
}
cout << names + '\n';
cout << max_tot << '\n';
cout << sum;
return 0;
}
这里空空如也








有帮助,赞一个