首页 > 代码库 > 1147. 谁拿了最多奖学金
1147. 谁拿了最多奖学金
#include<iostream>
using namespace std;
int main()
{
struct student{
string studentname;
int qimograde;
int banjigrade;
char xuesgb;
char xibxs;
int lunwen;
int sum;
};
int ts;
cin>>ts;
int n=ts;
student stu[ts];
for(int i=0;i<ts;i++){
cin>>stu[i].studentname;
cin>>stu[i].qimograde;
cin>>stu[i].banjigrade;
cin>>stu[i].xuesgb;
cin>>stu[i].xibxs;
cin>>stu[i].lunwen;
}
for(int i=0;i<n;i++){
stu[i].sum = 0;
if(stu[i].qimograde>80&&stu[i].lunwen>=1) stu[i].sum+=8000;
if(stu[i].qimograde>85&&stu[i].banjigrade>80) stu[i].sum+=4000;
if(stu[i].qimograde>90) stu[i].sum+=2000;
if(stu[i].qimograde>85&&stu[i].xibxs==‘Y‘) stu[i].sum+=1000;
if(stu[i].banjigrade>80&&stu[i].xuesgb==‘Y‘) stu[i].sum+=850;
}
int count=0;
int total=0;
int max=stu[0].sum;
for(int i=0;i<n;i++){
total += stu[i].sum;
if(stu[i].sum>max) {
max=stu[i].sum;
count=i;
}
}
cout<<stu[count].studentname<<endl;
cout<<stu[count].sum<<endl;
cout<<total<<endl;
return 0;
}
1147. 谁拿了最多奖学金