what?
2024-06-19 18:53:08
发布于:广东
16阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long n;
cin>>n;
string name[n];
long long score[n],class_score[n],lunwen[n],sum_score[n];
char student_gb[n],student_xb[n];
memset(sum_score,0,sizeof(sum_score));
for(int i=0;i<n;i++)
{
cin>>name[i]>>score[i]>>class_score[i]>>student_gb[i]>>student_xb[i]>>lunwen[i];
}
for(int i=0;i<n;i++)
{
if(score[i]>80 and lunwen[i]>=1)
{
sum_score[i]=sum_score[i]+8000;
}
else if(score[i]>85 and class_score[i]>80)
{
sum_score[i]=sum_score[i]+4000;
}
else if(score[i]>90)
{
sum_score[i]=sum_score[i]+2000;
}
else if(score[i]>85 and student_xb[i]=='Y')
{
sum_score[i]=sum_score[i]+1000;
}
else if(class_score[i]>80 and student_gb[i]=='Y')
{
sum_score[i]=sum_score[i]+850;
}
}
long long mx=-999999;
long long sum=0;
for(int i=0;i<n;i++)
{
mx=max(mx,sum_score[i]);
sum=sum+sum_score[i];
}
for(int i=0;i<n;i++)
{
if(sum_score[i]==mx)
{
cout<<name[i]<<endl<<sum_score[i]<<endl<<sum;
return 0;
}
}
}
全部评论 1
不要用else if,用if。
2024-06-19 来自 浙江
0
有帮助,赞一个