您的位置:首页 > 其它

tyvj p1002- 谁拿了最多奖学金[模拟]

2014-08-16 22:44 288 查看
#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
using namespace std;
struct stu
{
string name;
int no;
int score, score_2, paper, money = 0;
char leader, western;
}student[105];

bool cmp(const stu &s1, const stu &s2)
{
if(s1.money == s2.money)
return s1.no < s2.no;
else
return s1.money > s2.money;
}

int main()
{
int n;
scanf("%d", &n);
long long sum = 0;

for(int i = 1; i <= n; ++i)
{
cin >> student[i].name >> student[i].score >> student[i].score_2 >> student[i].leader >> student[i].western >> student[i].paper;
student[i].no = i;
if(student[i].paper >= 1 && student[i].score > 80)
student[i].money += 8000;
if(student[i].score > 85 && student[i].score_2 > 80)
student[i].money += 4000;
if(student[i].score > 90)
student[i].money += 2000;
if(student[i].score > 85 && student[i].western == 'Y')
student[i].money += 1000;
if(student[i].score_2 > 80 && student[i].leader == 'Y')
student[i].money += 850;
}
for(int i = 1; i <= n; ++i)
sum += student[i].money;
sort(student+1, student+1+n, cmp);
/*int maxn = 0, number;
for(int i = 1; i <= n; ++i)
{
if(student[i].money > maxn)
{
maxn = student[i].money;
number = i;
}
}
*/
cout << student[1].name << endl;
cout << student[1].money << endl;
cout << sum << endl;
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: