您的位置:首页 > 其它

NYoj 60 谁获得了最高奖学金

2014-04-24 21:10 411 查看
题目来源:http://acm.nyist.net/JudgeOnline/problem.php?pid=60

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int MAXN = 110;

struct studentNode
{
char name[21];
int average;
int evalute;
bool IsWest;
bool IsLeader;
int iPublishedNum;
int scholarship;
studentNode()
{
memset(name, 0, sizeof(name));
average = evalute = iPublishedNum = scholarship = 0;
IsWest = IsLeader = false;
}
}iStudent[MAXN];

int main()
{
int T, n, iMax, iPos, i, all;
scanf("%d", &T);
char c1, c2;
while(T--)
{
scanf("%d", &n);
memset(iStudent, 0, sizeof(iStudent));
for(i = 0; i < n; ++i)
{
scanf("%s %d %d %c %c %d", iStudent[i].name, &iStudent[i].average, &iStudent[i].evalute, &c1, &c2, &iStudent[i].iPublishedNum);
if(c2 == 'Y')
iStudent[i].IsWest = true;
else
iStudent[i].IsWest = false;
if(c1 == 'Y')
iStudent[i].IsLeader = true;
else
iStudent[i].IsLeader = false;
}
iMax = 0, iPos = 0, all = 0;
for(i = 0; i < n; ++i)
{
if(iStudent[i].average > 80 && iStudent[i].iPublishedNum >= 1)
iStudent[i].scholarship += 8000, all += 8000;
if(iStudent[i].average > 85 && iStudent[i].evalute > 80)
iStudent[i].scholarship += 4000, all += 4000;
if(iStudent[i].average > 90)
iStudent[i].scholarship += 2000, all += 2000;
if(iStudent[i].average > 85 && iStudent[i].IsWest)
iStudent[i].scholarship += 1000, all += 1000;
if(iStudent[i].evalute > 80 && iStudent[i].IsLeader)
iStudent[i].scholarship += 850, all += 850;
if(iMax < iStudent[i].scholarship)
{
iMax = iStudent[i].scholarship;
iPos = i;
}
}
printf("%s\n%d\n%d\n", iStudent[iPos].name, iStudent[iPos].scholarship, all);
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: