- 谁拿了最多奖学金
- 2016-10-15 21:18:19 @
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
struct student
{
string name;
int score;
int pingyi;
char leader;
char west;
int paper;
};
int main()
{
freopen("p1001.in", "r", stdin);
int num;
cin >> num;//学生个数
int ans[num+1];//奖学金
struct student stu[num+1];//学生
memset(ans, 0, sizeof(ans));//初始化奖学金为零
for(int i=1;i<=num;i++)//读入学生信息
{
cin >> stu[i].name;
cin >> stu[i].score;
cin >> stu[i].pingyi;
cin >> stu[i].leader;
cin >> stu[i].west;
cin >> stu[i].paper;
}
for(int j=1;j<=num;j++)
{
if(stu[j].score > 80 && stu[j].paper >=1)
ans[j] += 8000;
if(stu[j].score > 85 && stu[j].pingyi > 80)
ans[j] += 4000;
if(stu[j].score > 90)
ans[j] += 2000;
if(stu[j].west == 'Y' && stu[j].score > 85)
ans[j] += 1000;
if(stu[j].pingyi > 80 && stu[j].leader == 'Y')
ans[j] += 850;
}
int max = 0;//记录最大值
int flag;//记录第几个学生最大
for(int i=1;i<=num;i++)
{
if(ans[i] > max)
{
max = ans[i];
flag = i;
}
}
int total=0;//记录N个学生奖学金总数
for(int j=1;j<=num;j++)
total += ans[j];
cout << stu[flag].name << endl;
cout << max << endl;
cout << total << endl;
return 0;
}