NYOJ-60谁得了最高奖学金

呵呵,我完全是顺着描述用链表编的。


代码如下:

#include<stdio.h>

#include<string.h>

#include<stdlib.h>

struct Stud{

         charname[21];

         floatfinal_score;

         floatclass_review_score;

         chary_n_cadre;

         chary_n_western_provinces;

         intnumber_of_papers;

         structStud *next;

};

struct M{

         charname[21];

         intmoney;

         intsum;

};

int main()

{

         structStud *head,*ptr,*p;

         structM m;

         intN;

         intX;

         intlen;

         intmoney;

         len=sizeof(structStud);

         scanf("%d",&N);

         while(N--)

         {

                   head=(structStud *)malloc(len);

                   ptr=head;

                   scanf("%d",&X);

                   do

                   {

                            scanf("%s%f %f %c %c%d",ptr->name,&ptr->final_score,&ptr->class_review_score,&ptr->y_n_cadre,

                                     &ptr->y_n_western_provinces,&ptr->number_of_papers);

                            p=ptr;

                            ptr->next=(structStud *)malloc(len);

                            ptr=ptr->next;

                   }while(--X);

                   free(ptr);

                   p->next=NULL;

                   strcpy(m.name,head->name);

                   m.money=0;

                   m.sum=0;

                   for(ptr=head;ptr!=NULL;ptr=ptr->next)

                   {

                            money=0;

                            if((ptr->final_score>80)&&(ptr->number_of_papers>=1))

                                     money+=8000;

                            if((ptr->final_score>85)&&(ptr->class_review_score>80))

                                     money+=4000;

                            if(ptr->final_score>90)

                                     money+=2000;

                            if((ptr->final_score)>85&&(ptr->y_n_western_provinces=='Y'))

                                     money+=1000;

                            if((ptr->class_review_score>80)&&(ptr->y_n_cadre=='Y'))

                                     money+=850;

                            if(money>m.money)

                            {

                                     m.money=money;

                                     strcpy(m.name,ptr->name);

                            }

                            m.sum+=money;

                   }

                   printf("%s\n%d\n%d\n",m.name,m.money,m.sum);

                   ptr=head;

                   while(ptr!=NULL)

                   {

                            ptr=ptr->next;

                            free(head);

                            head=ptr;

                   }

         }

         return0;

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值