资源描述
算法与数据结构课程设计综合实验课程设计名称:学生成绩管理系统 专 业:计算机科学与技术 学生成绩管理系统一、 问题的描述和分析问题的描述 随着社会的发展和经济时代的到来,管理信息系统在各行各业都越来越重要,特别是教育事业。在经济发达的国家,许多教育机构(如公办、私立、培训机构等),都投入了大量的资金开发MIS系统,以求在将来激烈的竞争中立于不败之地。在我国,民办教育是新兴的一个行业,是随着改革开放和市场经济的发展根据中国特有的国情发展起来的,特别是中国民办教育促进法的出台,从一定的程度上规范和促进了中国民办教育的发展,这是一个很有发展前途的新兴产业,但是同发达国家相比,我国的民办教育行业的信息技术的应用程度还很低,只有在大城市中发展较早、规模较大的民办院校中才使用计算机进行大规模操作,从各方面提高工作效率,取得良好的社会和经济效益,而一些新兴的、规模较小的民办机构还没有全部具备这种功能。因此可见,随着我国民办教育的迅速发展,信息技术在其上的应用会更加地广泛和深入。现有系统存在问题的分析 有的学校根本就没有系统,还是手工操作计算机日新月异的发展,但是有的领导只见眼前利益,不关心,甚至不敢尝试新兴的事物。手工操作还十分落后,效率极低,成本很大,以后的社会是信息的社会,信息只有快,准,精才能发挥其价值。 所以机器代替人力是必然的历史发展趋势,只有领导的重视和支持才能从人工操作改为计算机的自动化系统。人工操作必将被计算机代替。 有些学校虽使用了计算机,甚至管理系统,但是仍然存在很多问题,问题一日不解决,效率就一日提不上去。 还有,有的系统很不完善到处是漏洞,可以说是千疮百孔,这样极不完善的系统能有保障吗?所以制作一个完善的学生管理系统是必不可少的。二、数据结构的设计struct person char name20; long num; float math; float English; float chinese; float average; float sum;student;三、模块:学生成绩管理系统模块四、算法的设计此成绩管理系统中,要求用户输入的只是有字符型和数值型数据,所以我设计了下面函数来处理并对输出的数据进行检验。int N=0;Enter() FILE *fp; char ch; char ch2; char numstr20; struct person student2; clrscr(); fp=fopen(jie.txt,ab); if(fp=NULL) printf(cant open this file.n); printf(wait for a second with patience.nthe system is exiting.n); getch(); exit(0); else do printf(your name:); gets(student.name); printf(nyour num:); gets(numstr); student.num=atol(numstr); printf(nyour math:); gets(numstr); student.math=atof(numstr); printf(nyour English:); gets(numstr); student.English=atof(numstr); printf(nyour chinese:); gets(numstr); student.chinese=atof(numstr); student.sum=student.chinese+student.math+student.English; student.average=student.sum/3; fwrite(&student,sizeof(struct person),1,fp); N+; printf(Do you continue adding other students(Y/N)?n); ch=getchar(); getchar(); while(ch=y|ch=Y); printf(Show all(Y/N)?n); ch2=getchar(); getchar(); if(ch2=y|ch2=Y) Listall(); fclose(fp); return_confirm(); clrscr(); 当用户执行此查询任务时,系统会提示用户进行查询字段的选择,即按学号或按姓名进行查询。若此学生记录存在,则会打印输出此学生记录的信息。Search() char choice; char ch1; char ch2; char ch3; char ch4; char name20; long num; char numstr20; clrscr(); printf(*WAYS OF SEARCHING*n); printf(-n); printf(* 1.name *n); printf(* 2.num *n); printf(-n); printf(give your choice:n); choice=getchar(); getchar(); while(choice2|choice1) printf(Sorry.your choice is wrong.nplease give a correct one:n); choice=getchar(); getchar(); 3.根据姓名或学号进行查找 switch(choice) case 1:do Loop1: printf(input the name of students you want to search:n); gets(name); Search1(name); printf(GO ON SEARCHING BY NAEM(Y/N)?n); ch2=getchar(); getchar(); while(ch2=y|ch2=Y); printf(Search by other ways(Y/N)?n); ch3=getchar(); getchar(); if(ch3=y|ch3=Y) goto Loop2; break; case 2: do Loop2: printf(input the num of students you want to search:n); gets(numstr); num=atol(numstr); Search2(num); printf(GO ON SEARCHING BY NUM(Y/N)?n); ch1=getchar(); getchar(); while(ch1=y|ch1=Y); Search2(long num) FILE *fp; char ch; int flag=0; int t; clrscr(); fp=fopen(jie.txt,rb); if(fp=NULL) printf(cant open this file.n); printf(wait for a second with patience.nthe system is exiting.n); getch(); exit(0); else flag=0; t=0; while(fread(&student,sizeof(struct person),1,fp) if(num=student.num) printf(namettnumtchinesetEnglishtmathsumtaveragen); printf(%-10s%-6ld%n,student.name,student.num,student.chinese,student.English,student.math,student.sum,student.average); t=1; break; if(t=0) printf(Sorry.the student you are searching not existed.n); rewind(fp); fclose(fp); Search1(char *name) FILE *fp; char ch; int flag=0; int t; clrscr(); fp=fopen(jie.txt,rb); if(fp=NULL) printf(cant open this file.n); printf(wait for a second with patience.nthe system is exiting.n); getch(); exit(0); else flag=0; t=0; while(fread(&student,sizeof(struct person),1,fp) if(strcmp(name,student.name)=0) printf(namettnumtchinesetEnglishtmathsumtaveragen); printf(%-10s%-6ld%n,student.name,student.num,student.chinese,student.English,student.math,student.sum,student.average); t=1; break; if(t=0) printf(Sorry.the student you are searching not existed.n); rewind(fp); fclose(fp); Delete() FILE *fp; struct person student130,student230; int i; int k; int j; int flag; char ch1; char name20; char ch; char ch2; clrscr(); fp=fopen(jie.txt,rb+); if(fp=NULL) printf(cant open this file.n); printf(wait for a second with patience.nthe system is exiting.n); getch(); exit(0); else do i=0; j=0; flag=0; printf(input the name of students you are going to delete.n); scanf(%s,name); while(fread(&student,sizeof(struct person),1,fp)=1) if(strcmp(name,student.name)!=0) student2j=student; j+; else flag=1; printf(nametttnumtchinesettEnglishttmathtsumtaveragen); printf(%-10s%-6ld%n,student.name,student.num,student.chinese,student.English,student.math,student.sum,student.average); printf(Delete(Y/N)?n); ch1=getchar(); getchar(); toupper(ch); if(ch=N) goto Loop; printf(j=%dn,j); k=j; i=0; fclose(fp); if(flag=0) printf(Sorry.the student you are searching not existed.n); if(flag=1) printf(Congratulation!you succeed!n); fp=fopen(jie.txt,wb+); if(fp=NULL) printf(cant open this file.n); printf(wait for a second with patience.nthe system is exiting.n); getch(); exit(0); else i=0; do fwrite(&student2i,sizeof(struct person),1,fp); i+; while(i6|ch1) printf(Sorry.you put is wrong.nplease input another choice:n); ch=getchar(); getchar(); switch(ch) case 1:ass_revise(name); gets(student.name); break; case 2:ass_revise(num); gets(numstr); student.num=atol(numstr); break; case 3:ass_revise(math); gets(numstr); student.math=atof(numstr); break; case 4:ass_revise(English); gets(numstr); student.English=atof(numstr); break; case 5:ass_revise(chinese); gets(numstr); student.chinese=atof(numstr); break; case 6:ass_revise(total); gets(student.name); ass_revise(num); gets(numstr); student.num=atol(numstr); ass_revise(math); gets(numstr); student.math=atof(numstr); ass_revise(English); gets(numstr); student.English=atof(numstr); ass_revise(chinese); gets(numstr); student.chinese=atof(numstr); student.sum=student.chinese+student.math+student.English; student.average=student.sum/3; printf(Continue revising the same student(Y/N)?n); ch1=getchar(); getchar(); while(ch=y|ch=Y); fseek(fp,-offset,1); fwrite(&student,sizeof(struct person),1,fp); printf(the following is information of student had been revised:n); printf(namettnumtmathtchinesetEnglishtsumtaveragen); printf(%-10s%-6ld%n,student.name,student.num,student.chinese,student.English,student.math,student.sum,student.average); printf(Congratulation!you succeed!n); break; while(fread(&student,sizeof(struct person),1,fp); rewind(fp); if(flag=0) printf(Sorry.the student of reving not existed.n); printf(GO ON Revising(Y/N)?n); ch1=getchar(); getchar(); if(ch1=y|ch1=Y) goto again; fclose(fp); return_confirm(); clrscr();Order() FILE *fp; char ch; char ch2; int k; float a30,b30,c30,d30; struct person student130; int i; char ch1; fp=fopen(jie.txt,rb); if(fp=NULL) printf(cant open this file.n); printf(wait for a second with patience.nthe system is exiting.n); getch(); exit(0); rewind(fp); i=0; while(fread(&student1i,sizeof(struct person),1,fp) i+; k=i; do for(i=0;ik;i+) ai=student1i.math; bi=student1i.English; ci=student1i.chinese; di=student1i.average; printf( *WAYS OF ORDER* n); printf(=n); printf(*1.math 2.English*n); printf(*3.chinese 4.average*n); printf(=n); printf(please give a choice:n); ch=getchar(); getchar(); while(ch4) printf(Sorry.the date you input is wrong.nplease give another choice:n); ch=getchar(); getchar(); switch(ch) case 1:Order1(a); break; case 2:Order1(b); break; case 3:Order1(c); break; case 4:Order1(d); break; printf(Congratulation!you succeed!n); printf(Go on ordering(Y/N)?n); ch1=getchar(); getchar(); while(ch1=y|ch=Y); printf(Show all(Y/N)?n); ch2=getchar(); getchar(); if(ch2=y|ch2=Y) rewind(fp); printf(nametttnumtchinesettEnglishttmathtsumtaveragen); while(fread(&student,sizeof(struct person),1,fp) printf(%-10s%-6ld%n,student.name,student.num,student.chinese,student.English,student.math,student.sum,student.average); fclose(fp); return_confirm(); Order1(float *p) FILE *fp; int i=0; int k; int j; struct person student2; struct person student130; clrscr(); fp=fopen(jie.txt,r+); if(fp=NULL) printf(cant open this file.n); printf(wait for a second with patience.nthe system is exiting.n); getch(); exit(0); else while(fread(&student1i,sizeof(struct person),1,fp) i+; k=i; i=0; while(ik) for(j=i+1;jk;j+) if(pipj) student2=student1i; student1i=student1j; student1j=student2; i+; rewind(fp); for(i=0;ik;i+) fwrite(&student1i,sizeof(struct person),1,fp); fclose(fp);由于记录显示操作经常进行,所以我将这分由独立的函数来实现,减少代码的重复。Listall() FILE *fp; char ch; struct person student130; int i; int k; fp=fopen(jie.txt,r); if(fp=NULL) printf(cant open this file.n); printf(wait for a second with patience.nthe system is exiting.n); getch(); exit(0); else do rewind(fp); printf(nametttnumtchinesettEnglishttmathtsumtaveragen); while(fread(&student,sizeof(struct person),1,fp) printf(%-10s%-6ld%n,student.name,student.num,student.chinese,student.English,student.math,student.sum,student.average); printf(GO ON(Y/N)?n); ch=getchar(); getchar(); while(ch=y|ch=Y); fclose(fp); return_confirm();四、具体程序的实现#includestdio.h#includestring.h#includestdlib.h#includectype.hstruct personchar name20;long num;float math;float English;float chinese;float average;float sum;student;int N=0;Enter() FILE *fp; char ch; char ch2; char numstr20; struct person student2; clrscr(); fp=fopen(jie.txt,ab); if(fp=NULL) printf(cant open this file.n); printf(wait for a second with patience.nthe system is exiting.n); getch(); exit(0); else do printf(your name:); gets(student.name); printf(nyour num:); gets(numstr); student.num=atol(numstr); printf(nyour math:); gets(numstr); student.math=atof(numstr); printf(nyour English:); gets(numstr); student.English=atof(numstr); printf(nyour
展开阅读全文