题目60 谁获得了最高奖学金

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/izhouxiaofei/article/details/52062574

       注意对是否是学生干部、和是否是西部学生的输入,如果用%c的话记得加上空格,scanf("%c %c",&stuent, &wes);

       已AC代码:

#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int t;
    scanf("%d", &t);
    while(t--)
    {
        int n;
        scanf("%d", &n);
        char name[35], exam[35];
        int avg0, avg1, l, temp=0, tend, sum=0;
        char stu[4], wes[4];
        for(int i=0; i<n; i++)
        {
            tend=0;
            scanf("%s%d%d", name, &avg0, &avg1);
            scanf("%s%s%d", stu, wes, &l);
            if(avg0>80 && l>=1)
                tend += 8000;
            if(avg0>85 && avg1>80)
                tend += 4000;
            if(avg0>90)
                tend += 2000;
            if(avg0>85 && wes[0]=='Y')
                tend += 1000;
            if(avg1>80 && stu[0]=='Y')
                tend += 850;
            sum += tend;
            if(tend > temp)
            {
                strcpy(exam, name);
                temp = tend;
            }
        }
        printf("%s\n%d\n%d\n", exam, temp, sum);
    }
    return 0;
}
        


阅读更多

没有更多推荐了,返回首页