资源描述
“学生学习成绩管理系统”用于对学生学习成绩数据文件的新文件创建和老文件管理,并可以进行密码设置。具体要求实现的功能如下:1、输入添加记录:将每一个学生的学号、姓名和各科学习成绩作为一个记录进行输入或添加。要求经过密码验证后能建立一个新的数据文件或给已建立好的数据文件增加记录。2、显示、查询记录:能按学生姓名(或学号)显示、查询一个或多个学生的各门(或某门)功课的成绩和平均成绩。3、修改记录:可以对数据文件中的任意记录的数据进行修改,在修改前后对该记录的内容进行显示,并设确认提示。(要求设置密码,验证通过后方可进入修改环节)4、删除记录:可以删除数据文件中的任一记录,包括逻辑删除(具有恢复功能)和物理删除(不可恢复)。(说明:该功能也应设置为经过验证密码后才可实施删除)5、成绩排序:采用不同的排序方法对单科成绩和总(或平均)成绩进行排序,但不能改变原记录的顺序。6、统计功能:(A)计算各门课程全班总成绩及平均成绩;(B)统计各门课程得分为100、9099、8089、7079、6069和不及格学生的人数,以及与全班总人数的百分比。7、其他:该软件应具有系统名称、设计单位或个人等基本信息。学生成绩管理系统源程序清单:#include#include#include#include#define NULL 0#define LEN sizeof(student)#define N 5typedef struct stuint flag;long num;char name10;int scoreN;struct stu *next;student;void edit();/*编辑菜单*/void search(student *head); /*查找函数*/student *search_number(student *head,long number); /*按学号查找*/void search_name(student *head); /*按姓名查找*/student *search_score(student *head,int min,int max,int i); /*按成绩查找*/void enter_record(student *p); /*输入成绩*/student *creat(void); /*建立链表*/student * insert(student *head); /*插入结点*/void count(int *p); /*计算总成绩及平均成绩*/void print(student *p); /*输出结点*/void print_title();/*输出标题*/student *delete(student *head); /*删除结点*/void recover(student *head); /*恢复删除*/void revise(student *head); /*修改记录*/void tongji(student *head); /*统计*/void paixu(student *head,int m); /*排序*/int cipher_check();/*密码检测*/void set_up_cipher();/*设立密码*/student *load();/*载入*/void save(student *head); /*保存*/void about();/*关于*/int n;char cipher11=;/*字符串,保存密码*/main()char c;student *head=NULL;system(cls);about();for(;)system(cls);printf(*n);printf(tt Welcome ton);printf(ntt The student score manage systemn);printf(*MENU*n);printf(ttt1. Creat the recordn);printf(ttt2. Load the filen);printf(ttt3. Edit the recordn);printf(ttt4. About designn);printf(ttt5. Quitn);printf(*n); printf(ntttEnter your choice(15):);for(;) c=getchar(); if(c=n) continue; else if(c5) printf(tttEnter your choice(15):); else break; getchar();switch (c) case 1: head=creat(); if(head=NULL) printf(Empty record!nnEnter any key to continue.n); getch(); break; set_up_cipher(); printf(Enter any key to edit menu.); getch(); edit(head);break; case 2: head=load(); if(head=NULL) printf(nEnter any key to continue.); getch();break; printf(Enter any key to edit menu.); getch(); edit(head); break; case 3:edit(head);break; case 4:about();break; case 5:exit(0); void edit(student *head)/*编辑菜单*/char c,m;int i,f=0;for(;)system(cls);printf(*EDIT*MENU*n);printf(ttt1.Save the record.n);printf(ttt2.Insert a record.n);printf(ttt3.Delete a record.n);printf(ttt4.Recover the record.n);printf(ttt5.Revise the record.n);printf(ttt6.Search records.n);printf(ttt7.Sort the records.n);printf(ttt8.Tongji the records.n);printf(ttt9.Change the password.n);printf(ttt0.Return to main menu.n);printf(*n);printf(tttEnter your choice(09):);for(;) c=getchar(); if(c=n) continue; else if(c9) printf(tttEnter your choice(09):); else break; switch (c) case 1:save(head);f=0;break; case 2: printf(Please enter the right password:n); if(cipher_check()=0) printf(Wrong password!n); break; head=insert(head);f=1;break; case 3: printf(Please enter the right password:n); if(cipher_check()=0) printf(Wrong password!n); break; head=delete(head);f=1;break; case 4: printf(Please enter the right password:n); if(cipher_check()=0) printf(Wrong password!n); break; recover(head);f=1;break; case 5: printf(Please enter the right password:n); if(cipher_check()=0) printf(Wrong password!n); break; revise(head);f=1;break; case 6: search(head);break; case 7: printf(Sort on which subject?n); printf(score1(1)/score2(2)/score3(3)/sum(4)n); for(;) scanf(%c,&m); if(m=n) ; else if(m=1&mnum);head=NULL;while(p1-num!=0) n+; enter_record(p1); if(n=1) head=p1; else p2-next=p1; p2=p1; p1=(student *)malloc(LEN); printf(Please enter next number(0 to end):n); scanf(%ld,&p1-num); if(n!=0) p2-next=NULL;free(p1);return head;student * insert(student *head) /*插入结点*/student *p1,*p2,*new_node;for(;) new_node=(student *)malloc(LEN); if(new_node=NULL) printf(Database is full,cant add more record.n); return NULL; printf(nPlease enter the number you want to insertn(enter 0 to end):); scanf(%ld,&new_node-num); if(new_node-num=0) break; for(p1=head,p2=NULL; p1!=NULL&(new_node-num)(p1-num); p2=p1,p1=p1-next) ; if(p1!=NULL&(p1-num)=(new_node-num)&p1-flag=1) char c; printf(This number already exists:n); print_title(); print(p1); printf(Cover or not?(y/n)?); for(;) c=getchar(); if(c=n|c=N) free(new_node);break; else if(c=y|c=Y) free(new_node);enter_record(p1);break; else if(c!=n) printf(Error!enter again:); else continue; else if(p1!=NULL&(p1-num)=(new_node-num) n+; free(new_node); enter_record(p1); else n+; enter_record(new_node); new_node-next=p1; if(p2=NULL) head=new_node; else p2-next=new_node; return head;student *delete(student *head) /*删除结点*/long number;char c;student *p1,*p2;for(;) printf(Please enter the number you want to delete(enter 0 to end):n); scanf(%ld,&number); if(!number) break; for(p1=head,p2=NULL; p1!=NULL&p1-num!=number; p2=p1,p1=p1-next) ; if(p1=NULL|p1-flag=0) printf(this number doesnt exist.n); else print_title(); print(p1); printf(delete this record?n); printf(sure(s)/cancle(c)/delete thoroughly(t)n); for(;) c=getchar(); if(c=c|c=C) break; else if(c=s|c=S|c=t|c=T) n-; if(c=s|c=S) p1-flag=0; else if(p2=NULL) head=p1-next; else p2-next=p1-next; free(p1); break; else if(c!=n) printf(error!enter again:); return head;void recover(student *head) /*恢复删除*/student *p;long number;printf(recover which number?n);scanf(%ld,&number);if(number=0) return;p=search_number(head,number);if(p=NULL) printf(Cant recover this number!n);else if(p-flag=1) printf(This number has not been deleted.n);else n+;p-flag=1;printf(Recover success!n);void revise(student *head) /*修改记录*/char c;long number;student *p1;for(;) printf(Which number do you want to revise?n(enter 0 to end):); scanf(%ld,&number); if(number=0) return; p1=search_number(head,number); if(p1=NULL|p1-flag=0) printf(this number doesnt exist.n);continue; print_title(); print(p1); printf(Do you want to revise the record?(y/n)n); for(;) c=getchar(); if(c=n) continue; else if(c=n|c=N) break; else if(c=y|c=Y) printf(please enter new record:n); enter_record(p1); printf(the new record is:n); print_title(); print(p1); break; else printf(error,enter again:); void search(student *head) /*查找函数*/char c;int i,min,max;long number;student *p;printf(Please enter search conditions:n);printf(all(a)/number(n)/name(m)/score(s)/return(r)n);for(;) c=getchar(); if(c=n) continue; else if(c=s) printf(Which couse do you want to search?n); printf(score1(1)/score2(2)/score3(3)/total(4)/average(5); for(;) c=getchar(); if(c=n) continue; else if(c0&cnext,min,max,i) print(p); else switch(c) case a: print_title(); for(p=head;p!=NULL;p=p-next) if(p-flag=1) print(p); break; case n: printf(What number do you want to search?n); scanf(%ld,&number); p=search_number(head,number); if(p=NULL|p-flag=0) printf(This number doesnt exist!n); else print_title(); print(p); break; case m: search_name(head);break; case r: return; default :printf(this condition doesnt exist,Pleaseenter again:n); printf(all(a)/number(n)/name(m)/score(s)/return(r)n); continue; printf(Please enter search conditions:n); printf(all(a)/number(n)/name(m)/score(s)/return(r)n); student *search_number(student *head,long number) /*按学号查找*/student * p;for(p=head;p!=NULL&p-num!=number;p=p-next);return p;void search_name(student *head) /*按姓名查找*/student *p1;char *p,str10;p=str;printf(please enter the name you want to search:n);scanf(%s,p);for(p1=head;p1!=NULL;p1=p1-next) if(p1-flag=0) continue; if(strcmp(p,p1-name)=0) break; if(p1=NULL) printf(this people doesnt exist.n);else print_title(); for(;p1!=NULL;p1=p1-next) if(strcmp(p,p1-name)=0&p1-flag=1) print(p1); student *search_score(student *head,int min,int max,int i) /*按成绩查找*/student *p1;for(p1=head;p1!=NULL;p1=p1-next) if(p1-flag=1&p1-scorei=min&p1-scoreinext) if(p-flag=0) continue; numberi=p-num; i+; for(i=0;iscorem; for(j=i+1;jscoremmax) max=p-scorem; k=j; if(k!=i) t=numberi; numberi=numberk; numberk=t; printf(*n);if(m=3) printf(Sord by sum score:n);else printf(Sord by score%d:n,m+1);printf(mingci );printf(number name score1 score2 score3 total avern);for(i=0;in;i+) printf(%4d ,i+1); print(search_number(head,numberi);void tongji(student *head) /*统计*/int i,sum,s,j;student *p1;printf(*n);printf( sum averagen);for(i=0;inext) if(p1-flag=1) sum+=p1-scorei; printf( score%d:%6d%9.2fn,i+1,sum,(float)sum/n); for(sum=0,p1=head;p1!=NULL;p1=p1-next) if(p1-flag=1) sum+=p1-scoreN-2;printf( sum :%6d%9.2fn,sum,(float)sum/n);printf(average:%6.2f%9.2fn,(float)sum/(N-2),(float)sum/(N-2)/n);printf(*n);printf(Ge fenshuduan renshu:n);printf( 100 90-99 80-89 70-79 60-69 failn);printf( score digit rate digit rate digit rate digit rate digit rate digit raten);for(i=0;i=60;s-=10) j=0; for(p1=search_score(head,s,s+9,i); p1!=NULL; p1=search_score(p1-next,s,s+9,i) j+; printf(%5d,%6.2f,j,(float)j/n); for(j=0,p1=search_score(head,0,59,i); p1!=NULL; p1=search_score(p1-next,0,59,i) j+; printf(%5d,%6.2f,j,(float)j/n); printf(n); void about()/*关于设计*/clrscr();printf(nnnnnn);printf(ttb*ABOUT*n);printf(ttb*tThe Student Score Manage Systemtt*n);printf(ttb*tttttt*n);printf(ttb*ttb llrsnake ttt*n);printf(ttb*ttb 1000000001ttt*n);printf(ttb*n);printf(ntttPress any key to return.);getch();student *load()/*载入*/FILE *fp;student *head=NULL,*p1,*p2;char c10;printf(please enter the file name:n);scanf(%s,c);if(fp=fopen(c,rb)=NULL) printf(Can not open the file %sn,c); return head; printf(loading.n);n=0;fgets(cipher,11,fp);p1=(student *)malloc(LEN);if(p1=NULL) printf(Out of memory!n); return(head); head=p1;while(!feof(fp) if(fread(p1,LEN,1,fp)!=1) break; n+; p1-next=(student *)malloc(LEN); if(!p1-next) printf(Out of memory!n); return (head); p2=p1; p1=p1-next; p2-next=NULL;fclose(fp);printf(load successfuly!n);return head;void save(student *head) /*保存*/FILE *fp;student *p;char str10;int i;printf(please enter the file name:n);scanf(%s,str);if(fp=fopen(str,wb)=NULL)printf(Cannot open file!n);return;printf(Saving.n);for(i=0;inext) if(fwrite(p,LEN,1,fp)!=1) printf(file save error!n);printf(save successfully!n);fclose(fp);int cipher_check()/*密码检测*/char c11;int i,flag;for(i=0;(ci=getch()!=r&i11;) if(ci=8) if(i=0) continue; else printf(b);clreol();i-;continue; if(i=10) continue; printf(*); i+; ci=0;printf(n);flag=!strcmp(c,cipher);return flag;void set_up_cipher()/*设立密码*/int i=0,flag;char c;printf(nPlease the password:n);while(cipheri=getch()!=r&iflag=1;printf(name:);scanf(%s,p-name);for(i=0;iscore)+i); if(p-scorei100|p-scoreiscore); void count(int *p) /*计算总成绩及平均成绩*/int i,sum=0,aver;for(i=0;inum,p-name);for(i=0;iscorei);printf(n);void print_title()/*输出标题*/printf(n*n);printf(number name score1 score2 score3 total avern);
展开阅读全文