NYOJ 60 谁获得了最高奖学金

题目: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;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值