人間夜行

一切の有為の法 夢幻泡影の如し

RQNOJ 16 谁拿了最多奖学金

| 评论

//读取数据时要极度小心。
#include <stdio.h>
int main()
{
        struct Student {
                char name[21];
                int score;
                int class;
                char gb;
                char west;
                int art;
                int money;
        } stu[101];
        int n;
        int i;
        scanf("%d",&n);
        for(i=1;i<=n;i++) scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].score,&stu[i].class,&stu[i].gb,&stu[i].west,&stu[i].art);
        for(i=1;i<=n;i++)
        {
                stu[i].money=0;
                if(stu[i].score>80&&stu[i].art>0) stu[i].money+=8000;
                if(stu[i].score>85&&stu[i].class>80) stu[i].money+=4000;
                if(stu[i].score>90) stu[i].money+=2000;
                if(stu[i].west=='Y'&&stu[i].score>85) stu[i].money+=1000;
                if(stu[i].gb=='Y'&&stu[i].class>80) stu[i].money+=850;
        }
        int max=0;
        int pos=0;
        int sum=0;
        for(i=1;i<=n;i++)
                if(stu[i].money>max)
                {
                        max=stu[i].money;
                        pos=i;
                        sum+=stu[i].money;
                }
                else sum+=stu[i].money;
        printf("%s\n",stu[pos].name);
        printf("%d\n",stu[pos].money);
        printf("%d",sum);
        return 0;
}

评论