呵呵,我完全是顺着描述用链表编的。
代码如下:
#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;
}