题目:NYOJ 60 谁获得了最高奖学金
其实这道题就是题目长了点,if语句比较多,写的时候注意细节,不然很容易出错
#include <stdio.h>
#include <string.h>
int main()
{
int n,m,i,s1,s,a,b,e,max;
char f[20],h[20],c,d;
scanf("%d",&n); //测试数据的组数
while(n--)
{
s1=0; //s1 为个人奖学金总数
s=0; //s 为奖学金总数
scanf("%d",&m); //每组的学生总数
scanf("%s %d %d %c %c %d",f,&a,&b,&c,&d,&e);
if(a>80 && e>=1) s1+=8000;
if(a>85 && b>80) s1+=4000;
if(a>90) s1+=2000;
if(a>85 && d=='Y') s1+=1000;
if(b>80 && c=='Y') s1+=850;
s+=s1;
max=s1; //max为最高奖学金
strcpy(h,f); //h[20]为获得最高奖学金的学生姓名
while(--m)
{
scanf("%s %d %d %c %c %d",f,&a,&b,&c,&d,&e);
s1=0;
if(a>80 && e>=1) s1+=8000;
if(a>85 && b>80) s1+=4000;
if(a>90) s1+=2000;
if(a>85 && d=='Y') s1+=1000;
if(b>80 && c=='Y') s1+=850;
if(s1>max) //如果有更高的奖学金
{
strcpy(h,f); //更换姓名
max=s1; //更换最高奖学金
}
s+=s1;
}
printf("%s\n%d\n%d\n",h,max,s);
}
return 0;
}