NYOJ 60谁获得了最高奖学金
2016-10-17 23:40
447 查看
原题目链接
判断每种情况的获得奖金就行,水一下~
#include <iostream>
#include <string>
using namespace std;
struct student
{
string name;
int argEnd;
int argCls;
char isLeader;
char isWester;
int num;
int getAward()
{
int res = 0;
if(argEnd>80 && num>=1)
res+=8000;
if(argEnd>85 && argCls>80)
res+=4000;
if(argEnd>90)
res+=2000;
if(argEnd>85 && isWester=='Y')
res+=1000;
if(argCls>80 && isLeader=='Y')
res+=850;
return res;
}
};
int main()
{
student stu[110];
int t,n;
int res,all,maxid;
cin>>t;
while(t--){
cin>>n;
res=all=maxid=0;
for(int i=0;i<n;i++){
cin>>stu[i].name>>stu[i].argEnd>>stu[i].argCls>>stu[i].isLeader>>stu[i].isWester>>stu[i].num;
int price = stu[i].getAward();
if(price>res){
maxid = i;
res = price;
}
all+=price;
}
cout<<stu[maxid].name<<endl<<res<<endl<<all<<endl;
}
return 0;
}
判断每种情况的获得奖金就行,水一下~
#include <iostream>
#include <string>
using namespace std;
struct student
{
string name;
int argEnd;
int argCls;
char isLeader;
char isWester;
int num;
int getAward()
{
int res = 0;
if(argEnd>80 && num>=1)
res+=8000;
if(argEnd>85 && argCls>80)
res+=4000;
if(argEnd>90)
res+=2000;
if(argEnd>85 && isWester=='Y')
res+=1000;
if(argCls>80 && isLeader=='Y')
res+=850;
return res;
}
};
int main()
{
student stu[110];
int t,n;
int res,all,maxid;
cin>>t;
while(t--){
cin>>n;
res=all=maxid=0;
for(int i=0;i<n;i++){
cin>>stu[i].name>>stu[i].argEnd>>stu[i].argCls>>stu[i].isLeader>>stu[i].isWester>>stu[i].num;
int price = stu[i].getAward();
if(price>res){
maxid = i;
res = price;
}
all+=price;
}
cout<<stu[maxid].name<<endl<<res<<endl<<all<<endl;
}
return 0;
}
相关文章推荐
- NYOJ60谁获得了最高奖学金
- NYOJ60 谁获得了最高奖学金
- NYOJ:60-谁获得了最高奖学金
- NYOJ 60 谁获得了最高奖学金
- NYOJ--60-题目-------------------------------谁获得了最高奖学金
- NYOJ-60-谁获得了最高奖学金-2013年09月18日08:51:06
- NYOJ 60 谁获得了最高奖学金
- NYOJ 60 谁获得了最高奖学金(结构体的应用)
- NYOJ--60 谁获得了最高奖学金【水题】
- nyoj60谁获得了最高奖学金
- NYOJ 60 谁获得了最高奖学金
- NYOJ 60谁获得了最高奖学金
- NYoj 60 谁获得了最高奖学金
- nyoj 60 谁获得了最高奖学金
- NYOJ60-谁获得了最高奖学金
- NSWOJ 1156 谁获得了最高奖学金 模拟 NYOJ 60
- 【NYOJ】[60]谁获得了最高奖学金
- NYOJ 60 谁获得了最高奖学金 2013年8月22日
- NYOJ 60 谁获得了最高奖学金【结构体】
- nyoj60谁获得了最高奖学金