1、C语言写的学生成绩管理系统链表152020年4月19日文档仅供参考#include#include#includestruct studlong num;char name20;float sx;float dx;float ts;float dl;float cx;float zf;float pj;struct studcodestruct stud student;struct studcode *next;void menu();void input(struct studcode *);void output(struct studcode *);void binsearch(str
2、uct studcode *);void insert(struct studcode *);void delet(struct studcode *);void good(struct studcode *);void fail(struct studcode *);void sort(struct studcode *);void back();void main()char choose;int flag=1;struct studcode *head;head=NULL;printf(请先录入学生成绩信息n);printf(输入学生学号 姓名 高数、英语读写、英语听说、计算机导论和程序
3、设计的成绩n);input(&head); while (flag) system(cls); menu(); printf(请选择:);getchar();choose=getchar();switch(choose) case 1: output(head); back(); break; case 2: binsearch(head); back(); break; case 3: insert(&head); output(head); back(); break; case 4: delet(&head); output(head); back(); break; case 5: g
4、ood(head); back(); break; case 6: fail(head); back(); break; case 7: sort(head); output(head); back(); break; case 0: flag=0; printf(n * The End! *n); printf(n #感谢使用,欢迎再次登录,拜拜!#n); break; default: printf(n Wrong Selection !(选择错误,请重选 )n); back(); void menu()printf( n 学生成绩统计与分析系统n);printf( n 菜 单nn);pr
5、intf( n 1. 显示所有学生的信息n); printf( n 2. 查找某学号的学生信息n);printf( n 3. 插入某学生的信息 n);printf( n 4. 删除某学号学生的信息n);printf( n 5. 统计各门课程成绩在90分以上学生所占百分比n);printf( n 6. 统计各门课程成绩在60分以下学生所占百分比 n);printf( n 7. 按总分降序排序,依高低排出名次 n);printf( n 0. 退出 nn);void back()int x;printf(n);doprintf(按1返回菜单界面:);scanf(%d,&x);while(x!=1);
6、void input(struct studcode *headp)struct studcode *p;while(1)p=(struct studcode *)malloc(sizeof(struct studcode);scanf(%ld,&p-student.num);if(p-student.num=0) break;scanf(%s%f%f%f%f%f,&p-student.name,&p-student.sx,&p-student.dx,&p-student.ts,&p-student.dl,&p-student.cx);p-student.zf=p-student.sx+p-s
7、tudent.dx+p-student.ts+p-student.dl+p-student.cx;p-student.pj=p-student.zf/5;p-next=*headp;*headp=p;void output(struct studcode *head)struct studcode *p;p=head;printf(学号t姓名t高数t读写t听说t导论t程序t总分t平均分n);while(p!=NULL)printf(%-ldt%-4st%-0.2ft%-0.2ft%-0.2ft%-0.2ft%-0.2ft%-0.2ft%-0.2fn,p-student.num,p-studen
8、t.name,p-student.sx,p-student.dx,p-student.ts,p-student.dl,p-student.cx,p-student.zf,p-student.pj);p=p-next;printf(n);void binsearch(struct studcode *head)struct studcode *p;int k=1;long x;p=head;printf(请输入需要查找的学生的学号:);scanf(%ld,&x); printf(n);while(p!=NULL)if(p-student.num=x)printf(该学生信息如下:n);print
9、f(学号t姓名t高数t读写t听说t导论t程序t总分t平均分n); printf(%-ldt%-4st%-0.2ft%-0.2ft%-0.2ft%-0.2ft%-0.2ft%-0.2ft%-0.2fn,p-student.num,p-student.name,p-student.sx,p-student.dx,p-student.ts,p-student.dl,p-student.cx,p-student.zf,p-student.pj);k=0;break;p=p-next;if(k) printf(没有此学生的信息n);void insert(struct studcode *headp)s
10、truct studcode *p;p=(struct studcode *)malloc(sizeof (struct studcode);printf(请输入你想插入的学生的信息n);scanf(%ld%s%f%f%f%f%f,&p-student.num,&p-student.name,&p-student.sx,&p-student.dx,&p-student.ts,&p-student.dl,&p-student.cx);p-student.zf=p-student.sx+p-student.dx+p-student.ts+p-student.dl+p-student.cx;p-st
11、udent.pj=p-student.zf/5; p-next=*headp;*headp=p;printf(*插入成功*n);void delet(struct studcode *headp)struct studcode *p,*last;long x;p=*headp;printf(请输入你要删除的学生的学号:);scanf(%ld,&x);while(p-student.num!=x&p-next!=NULL)last=p;p=p-next;if(p-student.num=x)if(p=*headp)*headp=p-next;else last-next=p-next;free(
12、p);printf(n*删除成功*n);else printf(n*删除失败,无该学生信息*n);void good(struct studcode *head)struct studcode *p;int x1,x2,x3,x4,x5,k;float y1,y2,y3,y4,y5;x1=x2=x3=x4=x5=k=0;p=head;while(p!=NULL)k+;if(p-student.sx=90) x1+;if(p-student.dx=90) x2+;if(p-student.ts=90) x3+;if(p-student.dl=90) x4+;if(p-student.cx=90)
13、 x5+;p=p-next;y1=(float)x1/k;y2=(float)x2/k;y3=(float)x3/k;y4=(float)x4/k;y5=(float)x5/k;printf(高数t读写t听说t导论t程序n);printf(%-0.2ft%-0.2ft%-0.2ft%-0.2ft%-0.2fn,y1,y2,y3,y4,y5);void fail(struct studcode *head)struct studcode *p;int x1,x2,x3,x4,x5,k;float y1,y2,y3,y4,y5;x1=x2=x3=x4=x5=k=0;p=head;while(p!=
14、NULL)k+;if(p-student.sxstudent.dxstudent.tsstudent.dlstudent.cxnext;y1=(float)x1/k;y2=(float)x2/k;y3=(float)x3/k;y4=(float)x4/k;y5=(float)x5/k;printf(高数t读写t听说t导论t程序n);printf(%-0.2ft%-0.2ft%-0.2ft%-0.2ft%-0.2fn,y1,y2,y3,y4,y5);void sort(struct studcode *head)struct stud temp;int i,j,n;struct studcode *p,*p1,*p2;n=0;p=head;while(p!=NULL)n+;p=p-next;for(p1=head,i=0;inext)for(p2=p1-next,j=i+1;jnext)if(p1-student.zfstudent.zf)temp=p2-student;p2-student=p1-student;p1-student=temp;printf(n*排序成功*n);