结构体运用 + 分支加法
2023-08-10 12:07:53
发布于:上海
7阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
struct stu{
string name;
double chengj,pingj;
string ganbu,xibu;
int lun;
int money;
}a[10001];
int main(){
int n;
cin>>n;
int cnt=0,maxi=-999;string nao;
for(int i=0;i<n;i++){
cin>>a[i].name>>a[i].chengj>>a[i].pingj>>a[i].ganbu>>a[i].xibu>>a[i].lun;
a[i].money=0;
double o=a[i].chengj,p=a[i].pingj;
int j=a[i].lun;
string k=a[i].ganbu,l=a[i].xibu;
if(o>80.0 and j>=1) a[i].money+=8000;
if(o>85.0 and p>80.0) a[i].money+=4000;
if(o>90.0) a[i].money+=2000;
if(o>85.0 and l=="Y") a[i].money+=1000;
if(p>80.0 and k=="Y") a[i].money+=850;
if(a[i].money>maxi){
maxi=a[i].money;
nao=a[i].name;
}
cnt+=a[i].money;
}
cout<<nao<<endl;
cout<<maxi<<endl;
cout<<cnt;
return 0;
}
这里空空如也
有帮助,赞一个