#include#include struct Student { int yuwen; int shuxue; int yingyu; int ban; int ji; int zf; struct Student *next; }; struct Class { struct Student *xnext; struct Class *next; }; void wellcome() { printf("*************************************************************n"); printf("*************************************************************n"); printf("*************************************************************n"); printf("**********wellcome to the Student Management System**********n"); printf("*************************************************************n"); printf("*************************************************************n"); printf("*************************************************************n"); } struct Class *bjsf(struct Class *head,struct Class *new) { struct Class *p=head; if(p == NULL){ head=new; return head; } while(p->next != NULL){ p=p->next; } p->next=new; return head; } struct Student *xssf(struct Student *head,struct Student *new) { struct Student *p=head; if(p ==NULL){ head=new; return head; } while(p->next != NULL){ p=p->next; } p->next=new; return head; } struct Student *xs(struct Student *xshead,int i) { struct Student *new=NULL; int j; for(j=0;j<5;j++){ new=(struct Student *)malloc(sizeof(struct Student)); printf("please input %dclass %dge Student yuwen scoren",i+1,j+1); scanf("%d",&(new->yuwen)); while(new->yuwen < 0 || new->yuwen > 100){ printf("NO INPUTn"); scanf("%d",&(new->yuwen)); } printf("please input %dclass %dge Student shuxue scoren",i+1,j+1); scanf("%d",&(new->shuxue)); while(new->shuxue < 0 || new->shuxue > 100){ printf("NO INPUTn"); scanf("%d",&(new->shuxue)); } printf("please input %dclass %dge Student english scoren",i+1,j+1); scanf("%d",&(new->yingyu)); while(new->yingyu < 0 || new->yingyu > 100){ printf("NO INPUTn"); scanf("%d",&(new->yingyu)); } new->ban=i; new->ji=j; new->zf=new->yuwen+new->shuxue+new->yingyu; xshead=xssf(xshead,new); } return xshead; } struct Class *banji(struct Class *bjhead) { struct Class *new=NULL; struct Student *xshead=NULL; int i; for(i=0;i<5;i++){ new=(struct Class *)malloc(sizeof(struct Class)); xshead=xs(xshead,i); new->xnext=xshead; bjhead=bjsf(bjhead,new); } return bjhead; } void printflink(struct Class *head) { struct Student *xhead=NULL; xhead=head->xnext; int i,j; for(i=0;i<5;i++){ for(j=0;j<5;j++){ printf("%dclass%dstudent yuwen=%dn",i+1,j+1,xhead->yuwen); printf("%dclass%dstudent shuxue=%dn",i+1,j+1,xhead->shuxue); printf("%dclass%dstudent yingyu=%dn",i+1,j+1,xhead->yingyu); xhead=xhead->next; putchar('n'); } head=head->next; } } void findmax(struct Class *head) { int max; int i=0; int j=0; struct Student *xhead=NULL; xhead=head->xnext; max=xhead->zf; while(head != NULL){ while(xhead != NULL){ if(max < xhead->zf){ max=xhead->zf; i=xhead->ban; j=xhead->ji; } xhead=xhead->next; } head=head->next; } printf("max student from %dban%dge Student score sum=%dn",i+1,j+1,max); } void findmin(struct Class *head) { int min; int i=0; int j=0; struct Student *xhead=NULL; xhead=head->xnext; min=xhead->zf; while(head != NULL){ while(xhead != NULL){ if(min > xhead->zf){ min=xhead->zf; i=xhead->ban; j=xhead->ji; } xhead=xhead->next; } head=head->next; } printf("min Student from %dban%dge Student score sum=%dn",i+1,j+1,min); } void findpz(struct Class *head) { double sum=0; struct Student *xhead=NULL; xhead=head->xnext; while(head != NULL){ while(xhead != NULL){ sum+=xhead->zf; xhead=xhead->next; } head=head->next; } printf("Student zf=%.0lfn",sum); printf("Student pj=%.2fn",(float)sum/25); } int main() { struct Class *head=NULL; wellcome();//欢迎界面 head=banji(head);//建立班级链表 printflink(head);//打印刚才输入的成绩 findmax(head);//找到三门功课最高分 findmin(head);//找到三门功课最低分 findpz(head);//找到代码平均分和总分 return 0; }



