讨论 / AC100人人看得懂代码
潜力新星 2019-07-15 15:39:05
点我顶贴 收藏 删除
#include <bits/stdc++.h>

using namespace std;

struct node

{

string name;

int qimochengji;

int pingyichengji;

char ganbu,xibustudent;

int lunwenshu;

int money;

int bianhao;

}a[101];

int n;

bool cmp(node x,node y)//比较

{

return x.money>y.money||x.money==y.money&&x.bianhao<y.bianhao;

}

int main()

{

cin>>n;

int sum=0;

for(int i=1;i<=n;i++)

{

cin>>a[i].name>>a[i].qimochengji>>a[i].pingyichengji>>a[i].ganbu>>a[i].xibustudent>>a[i].lunwenshu;

a[i].bianhao=i;//注意,题目中有关于编号这一说,所以要记录编号

}

for(int i=1;i<=n;i++)//模拟

{

if(a[i].qimochengji>80&&a[i].lunwenshu>=1)

a[i].money+=8000;

if(a[i].qimochengji>85&&a[i].pingyichengji>80)

a[i].money+=4000;

if(a[i].qimochengji>90)

a[i].money+=2000;

if(a[i].qimochengji>85&&a[i].xibustudent=='Y')

a[i].money+=1000;

if(a[i].pingyichengji>80&&a[i].ganbu=='Y')

a[i].money+=850;

sum+=a[i].money;

}

sort(a+1,a+n+1,cmp);

cout<<a[1].name<<endl<<a[1].money<<endl<<sum;

return 0;

}

查看更多回复
提交回复