#include <bits/stdc++.h>
using namespace std;
struct Person {
string name;
int grade1; // 期末平均成绩
int grade2; // 班级评议成绩
char isBan; // 是否是学生干部 (Y/N)
char isXi; // 是否是西部省份学生 (Y/N)
int papers; // 发表论文数
int totalMoney; // 总奖金
};
bool compare(const Person& a, const Person& b) {
return a.totalMoney > b.totalMoney || (a.totalMoney == b.totalMoney && a.name < b.name);
}
int main() {
int n;
cin >> n;
vector<Person> students(n);
for (int i = 0; i < n; ++i) {
cin >> students[i].name >> students[i].grade1 >> students[i].grade2 >> students[i].isBan >> students[i].isXi >> students[i].papers;
students[i].totalMoney = 0;
// 计算各项奖学金
if (students[i].grade1 > 80 && students[i].papers >= 1) {
students[i].totalMoney += 8000;
}
if (students[i].grade1 > 85 && students[i].grade2 > 80) {
students[i].totalMoney += 4000;
}
if (students[i].grade1 > 90) {
students[i].totalMoney += 2000;
}
if (students[i].grade1 > 85 && students[i].isXi == 'Y') {
students[i].totalMoney += 1000;
}
if (students[i].grade2 > 80 && students[i].isBan == 'Y') {
students[i].totalMoney += 850;
}
}
// 找出奖金最高的学生
sort(students.begin(), students.end(), compare);
cout << students[0].name << endl;
cout << students[0].totalMoney << endl;
// 计算所有学生的总奖金
int totalScholarship = 0;
for (const auto& student : students) {
totalScholarship += student.totalMoney;
}
cout << totalScholarship << endl;
return 0;
}
HAUT OJ 1186: 奖学金(结构体专题)
最新推荐文章于 2024-11-11 16:07:51 发布