社区讨论
90分,求教
P1051[NOIP 2005 提高组] 谁拿了最多奖学金参与者 2已保存回复 2
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 2 条
- 当前快照
- 1 份
- 快照标识符
- @m5wbaziv
- 此快照首次捕获于
- 2025/01/14 18:10 去年
- 此快照最后确认于
- 2025/11/04 11:37 4 个月前
CPP
#include <iostream>
using namespace std;
struct student {
string name;
int egra, cgra, pasa, mon;
bool lead, west;
};
int sum(student a) {
int num = 0;
if (a.egra > 80 && a.pasa >= 1)
num += 8000;
if (a.egra > 85 && a.cgra > 80)
num += 4000;
if (a.egra > 90)
num += 2000;
if (a.egra > 85 && a.west)
num += 1000;
if (a.cgra > 80 && a.lead)
num += 850;
return num;
}
void sort_for(student *a, int b) {
for (int i = 0; i <= b - 1; i++) {
int p = i;
for (int j = i; j <= b - 1; j++) {
if (a[j].mon < a[p].mon)
p = j;
}
swap(a[i], a[p]);
}
}
void print(student *a, int n) {
for (int i = 0; i <= n - 1; i++) {
cout << "#" << a[i].name << ":" << a[i].egra << " " << a[i].cgra << " ";
if (a[i].lead)
cout << "Y" << " ";
else
cout << "N" << " ";
if (a[i].west)
cout << "Y" << " ";
else
cout << "N" << " ";
cout << a[i].pasa << endl;
}
return ;
}
int main() {
student a[100];
int n;
cin >> n;
for (int i = 0; i <= n - 1; i++) {
char k, s;
cin >> a[i].name >> a[i].egra >> a[i].cgra >> k >> s >> a[i].pasa;
if (k == 'Y')
a[i].lead = true;
else {
a[i].lead = false;
}
if (s == 'Y')
a[i].west = true;
else
a[i].west = false;
}
int mon[100], num = 0;
for (int i = 0; i <= n - 1; i++) {
a[i].mon = sum(a[i]);
num += a[i].mon;
}
sort_for(a, n);
cout << a[n - 1].name << endl << a[n - 1].mon << endl << num;
return 0;
}
回复
共 2 条回复,欢迎继续交流。
正在加载回复...