1、 double ave,zc; struct student *next;#define Len sizeof(struct student)int len; /链表长度int a=0,b=0,c=0,d=0,e=0;/用来存放成绩各阶的人数char stu10;struct student *Read() /读取数据文件保存到链表中,返回指向此链表头指针 struct student *head=NULL; struct student *p1, *p2; FILE *fp; coutstu; if(fp=fopen(stu,rb+)=NULL) cout打开文件出错! exit(0); w
2、hile(!feof(fp) if( (p1=(struct student*)malloc(Len)=NULL ) coutnext=p1; p2=p1; fclose(fp); return head;void save(struct student *head)/数据存盘 struct student *p; p=head;请输入你要存进去的文件(.dat) if(fp = fopen(stu, wb无法打开文件! system(pause); menu(); while(p) if(fwrite(p,Len,1,fp)!写入数据出错 return; p=p-next;数据存入成功!请按
3、任意键继续! getchar();/单次输入void sinput(struct student *p)coutp-number;请输入: name;请输入性别:sex;请输入家庭住址:adds;请输入联系:phone;请输入qq:qq;请输入语文成绩:chinese;if(p-chinese100|p-chinesemathenglishtxhppindeteacherchinese+p-math+p-english)/3.0;zc=(p-ave*0.6+p-txhp*0.1+p-pinde*0.2+p-teacher*0.1);你刚输入的信息为:tt学号:numbertt:namett性别
4、:sextt家庭住址:addstt联系:phonettQQ号:qqtt语文成绩:tt数学成绩:tt英语成绩:tt品德成绩:tt教师评分: return;/学生成绩录入函数struct student *input() struct student *head=NULL,*p1,*p2;/输入p1,p2链表最后节点 char ch=y; len=1; p2=p1=(struct student *)malloc(sizeof(struct student);请输入第lennext=NULL; paixu_num(head);输入学生信息完成!请按任意键返回主菜单!/学号排序void paixu_
5、num(struct student *head) struct student t,*r,*p,*q;/t交换p、q,r头结点 r=head; if(r=NULL) 学生信息不存在,请先输入学生信息! return; while(r) p=r; q=r- while(q) if(strcmp(q-number,p-number)0) /qnumber); strcpy(t.name,q-name); strcpy(t.sex,q-sex); strcpy(t.adds,q-adds); strcpy(t.phone,q-phone); strcpy(t.qq,q-qq); t.chinese
6、=q- t.math=q- t.english=q- t.txhp=q- t.pinde=q- t.teacher=q- strcpy(q-name,p-sex,p-adds,p-phone,p-qq,p- q-chinese=p-math=p-english=p-txhp=p-pinde=p-teacher=p- strcpy(p-number,t.number);name,t.name);sex,t.sex);adds,t.adds);phone,t.phone);qq,t.qq); p-chinese=t.chinese; p-math=t.math;english=t.english;
7、txhp=t.txhp;pinde=t.pinde;teacher=t.teacher; q=q- r=r-/插入函数struct student *insert() struct student *p,*p1,*head; head=Read(); p1=head; p=(struct student *)malloc(sizeof(struct student); char num14,ch;请输入你要插入的前一个学生的学号:num; while(p1) if(!strcmp(p1-number,num) sinput(p);next=p1- p1-next=p; len+; p1=p1-
8、 if(ch=学生信息插入成功!请按任意键返回!/修改学生信息struct student *alter() char temp13; struct student *p,*head;请输入要修改学生的学号:temp; while(p)strcmp(p-number,temp)学生信息修改成功!system(return head;/删除学生信息struct student *del() char temp13; int m=0; struct student *p1,*p,*head;/p1删除 p1=p=head;请输入你要删除学生的学号: while(p) if(strcmp(p1-nu
9、mber,temp)=0) if(p1=head)/删除的头结点 head=p1- else len-; m=1;学生信息删除成功!请按任意键返回主菜单. getchar(); return head; if(!m)查找不到这个信息!void find_num(struct student *head)/按学号查找 struct student *p=head; char temp9; int m = 0;请输入要查找的学生的学号while(p!=NULL) if(strcmp(p-number,temp) = 0)该学生的具体信息为:tt数学成绩tt英语成绩tt平均成绩avett品德成绩tt
10、老师评分tt综合成绩zcscore_paixu(head);tt考试名次ksmctt综测名次zcmc/继续向下寻找查找不到这个学号的信息!按任意键返回主菜单 return ;void find_name(struct student *head)/按查找 struct student *p= head;请输入要查找的学生的while(p) if(strcmp(p-name,temp) = 0)学号:void output() int i=1;tt老师评分:tt平均成绩:tt综合成绩:tt综合测评名次p=p-i+;请按任意键返回主菜单void max_student(struct student *head) struct student *p=head
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1