#正经题解#谁拿了最多奖学金
2025-09-25 19:52:12
发布于:江苏
1阅读
0回复
0点赞
详细解题步骤
1. 问题分析
·目标:计算每个学生的奖学金总额,找出获得最多的学生,并统计所有学生的总奖学金
·关键:每个学生可同时获得多项奖学金,需逐一判断是否符合各项条件
·注意:若有多名学生奖金相同,选择输入顺序中最早出现的学生
2. 数据准备
输入信息:学生姓名、期末平均成绩、班级评议成绩、是否学生干部、是否西部学生、发表论文数
奖学金种类及条件:
·院士奖学金 (8000 元):期末成绩 > 80 且论文≥1
·五四奖学金 (4000 元):期末成绩 > 85 且班级评议 > 80
·成绩优秀奖 (2000 元):期末成绩 > 90
·西部奖学金 (1000 元):期末成绩 > 85 且是西部学生
·班级贡献奖 (850 元):班级评议 > 80 且是学生干部
3. 算法设计
读取学生总数 N
初始化变量
循环处理每个学生
输出结果:最高奖学金获得者姓名、金额、总金额
AC代码:
#include <iostream>
#include <string>
using namespace std;
int main() {
int n;
cin >> n;
string mx_name = "";
int mx_money = -1;
int total = 0;
for (int i = 0; i < n; i++) {
string name;
int avg, eval, papers;
char leader, west;
cin >> name >> avg >> eval >> leader >> west >> papers;
int money = 0;
if (avg > 80 && papers >= 1) {
money += 8000;
}
if (avg > 85 && eval > 80) {
money += 4000;
}
if (avg > 90) {
money += 2000;
}
if (avg > 85 && west == 'Y') {
money += 1000;
}
if (eval > 80 && leader == 'Y') {
money += 850;
}
total += money;
if (money > mx_money) {
mx_money = money;
mx_name = name;
}
}
cout << mx_name << endl;
cout << mx_money << endl;
cout << total << endl;
return 0;
}
这里空空如也
有帮助,赞一个