- 谁拿了最多奖学金
- 2018-01-24 20:50:28 @
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=105;
struct qwe
{
char zxc[25],o,p;
int num1,num2,num3,sum1;
}a[N];
bool cmp(qwe q,qwe w)
{
return q.sum1>w.sum1;
}
int main()
{
int n,i,sum=0;
scanf("%d\n",&n);
for(i=1;i<=n;i++)
{
scanf("%s ",a[i].zxc);
scanf("%d %d ",&a[i].num1,&a[i].num2);
scanf("%c %c ",&a[i].o,&a[i].p);
scanf("%d\n",&a[i].num3);
if(a[i].num1>80&&a[i].num3>=1)
{
a[i].sum1+=8000;
sum+=8000;
}
if(a[i].num1>85&&a[i].num2>80)
{
a[i].sum1+=4000;
sum+=4000;
}
if(a[i].num1>90)
{
a[i].sum1+=2000;
sum+=2000;
}
if(a[i].num1>85&&a[i].p=='Y')
{
a[i].sum1+=1000;
sum+=1000;
}
if(a[i].num2>80&&a[i].o=='Y')
{
a[i].sum1+=850;
sum+=850;
}
}
sort(a+1,a+n+1,cmp);
printf("%s\n",a[1].zxc);
printf("%d\n",a[1].sum1);
printf("%d\n",sum);
}
1 条评论
-
重新燃起算法热情的小虾米 LV 6 @ 2018-03-05 12:15:34
我查了下并且做了实验,sort其实有点缺陷,排序方法的不固定性造成的
- 1