C语言课程设计---学生成绩管理系统设计.doc_第1页
C语言课程设计---学生成绩管理系统设计.doc_第2页
C语言课程设计---学生成绩管理系统设计.doc_第3页
C语言课程设计---学生成绩管理系统设计.doc_第4页
C语言课程设计---学生成绩管理系统设计.doc_第5页
已阅读5页,还剩14页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

学生成绩管理系统设计1、课程设计简介1.1 要求参加本课程设计的学生,应当认真完成本课程设计的全部过程。并以最终课程设计成果来证明其独立完成各种实际任务的能力。从而,反映出理解和运用本课程知识的水平和能力。1.2 意义和目的意义:C语言是电子科学与技术专业的重要专业基础课。在很多后续课程中,都要使用到C语言。学生通过对C语言的学习,已经具备了使用C语言编写简单的应用程序的能力。为了加强程序设计基础,开设课程设计课,使学生对C语言有更全面的理解,进一步提高运用C语言编程解决实际问题的能力,同时,为后续课程的学习夯实基础。目的:1)提高用程序设计解决实际问题的能力。2)通过提出算法、指定输入输出来设计一个解决方案。3)用C语言合理地开发两个简洁有效的程序代码来实现该设计。4)测试程序是否工作且满足设计指标并评价其效率。1.3 内容 链表文件操作题(包括文件输入、文件输出、链表建立、结点插入、结点删除、输出打印等)(参考教材);2、具体实现2.1 程序总体方案2.1.1程序设计思想 通过在主函数循环调用各个函数,从而实现文件输出及对链表的连续操作,最终实现链表的新建、打印、查找、保存、读取、更新、删除等等操作,进而管理学生信息,并保存学生的各种信息,方便下一次操作。链表是以学生学号排序,当出现学号为0时结束本次操作,成功实现一个学号对应一位学生。主函数1成绩录入2成绩查询7成绩输出6插入记录3不及格名单4修改记录5删除记录8退出2.1.2程序结构或流程图2.2 具体方案 2.2.1 首界面2.2.2文件输出struct student *read()/数据读取,写入内存;FILE *fp;struct student *p1,*p2,*head;head=NULL; p1=p2=(struct student *)malloc(LEN);if(fp=fopen(G:Cfile1.dat,rb)=NULL)head=NULL;fclose(fp); return(head);fread(p1,sizeof(struct student),1,fp);head=p1;while(p1-next!=NULL) p2=p1; p1=(struct student *)malloc(LEN); fread(p1,sizeof(struct student),1,fp);p2-next=p1; fclose(fp); return (head);用fread函数将文件中的数据项写入内存,返回head,为下面子函数的调用做准备。2.2.3 功能选择 switch(c) case 1: system(cls); printf(input record:n); head=creat();system(cls); print(head); save(head);getch(); break; case 2: head=read(); /进行读文件; system(cls); printf(n input the chaxun number:); head=read(); scanf(%ld,&cx_num); while(cx_num!=0) chaxun(head,cx_num); printf(n input the chaxun number:); scanf(%ld,&cx_num); save(head); break; case 3: head=read(); /进行读文件; system(cls); bujige(head); getch(); break; case 4: head=read(); /进行读文件; system(cls); printf(n input the xiugai record:); stu=(struct student*)malloc(LEN); printf(num=); scanf(%ld,&stu-lead.num); while(stu-lead.num!=0) printf(nname=); scanf(%s,); printf(语文、数学、英语成绩:); scanf(%f,%f,%f,&stu-lead.score0,&stu-lead.score1,&stu-lead.score2); stu-lead.aver=(stu-lead.score0+stu-lead.score1+stu-lead.score2)/3; xiugaijilu(head,stu); getch(); system(cls); printf(input the inserted record:); stu=(struct student*)malloc(LEN); printf(num=); scanf(%ld,&stu-lead.num); system(cls); print(head); save(head); getch(); break; case 5: head=read(); /进行读文件; system(cls); printf(n input the deleted number:); scanf(%ld,&del_num); while(del_num!=0) head=del(head,del_num); printf(n input the deleted number:); scanf(%ld,&del_num); system(cls); print(head); save(head); getch();break; case 6: head=read(); /进行读文件; printf(n input the inserted record:); stu=(struct student*)malloc(LEN); printf(num=); scanf(%ld,&stu-lead.num); while(stu-lead.num!=0) printf(nname=); scanf(%s,); printf(语文、数学、英语成绩:); scanf(%f,%f,%f,&stu-lead.score0,&stu-lead.score1,&stu-lead.score2); stu-lead.aver=(stu-lead.score0+stu-lead.score1+stu-lead.score2)/3; head=insert(head,stu); printf(input the inserted record:); stu=(struct student*)malloc(LEN); printf(num=); scanf(%ld,&stu-lead.num); print(head); save(head); getch(); break; case 7: head=read(); /进行读文件; system(cls); print(head); getch();break; default:printf(enter data error!n);break; 采用switch函数,实现各种功能的选择,既方便,又简洁。2.2.4成绩录入(链表建立)struct student *creat()/建立链表;struct student *head;struct student *p1,*p2;int n;n=0;p1=p2=(struct student *)malloc(LEN); head=NULL; printf(nnum=);scanf(%ld,&p1-lead.num);while(p1-lead.num!=0)printf(nname=);scanf(%s,);printf(n语文、数学、英语成绩:);scanf(%f,%f,%f,&p1-lead.score0,&p1-lead.score1,&p1-lead.score2); p1-lead.aver=(p1-lead.score0+p1-lead.score1+p1-lead.score2)/3;n=n+1;if(n=1)head=p1; elsep2-next=p1; p2=p1;p1=(struct student *)malloc(LEN);printf(nnum=);scanf(%ld,&p1-lead.num); p2-next=NULL;return(head); 该功能是建立链表;使用该功能时会将原有的数据清除,录入新的数据。如何想在原有数据的基础上再写入数据,则使用插入功能。2.2.5成绩查询void chaxun(struct student *head,long num)/记录查询;struct student *p;int n=0;p=head;while(p!=NULL) if(p-lead.num=num) system(cls); printf(nnn); printf(No. Name 语文成绩 数学成绩 英语成绩 平均分n); printf(%d %4s %10f %10f %10f %10fn,p-lead.num,,p-lead.score0,p-lead.score1,p-lead.score2,p-lead.aver); n=1; p=NULL; else p=p-next; if(n=0) printf(您所查询的记录不存在n); 该功能通过给定学号,再从链表头开始按顺序比较学号;如果有学号相等者,则输出该学号对应数据项的信息,否则输出“你所查询的记录不存在”。2.2.6输出不及格学生名单 void bujige(struct student *head)/不及格名单;struct student *p;p=head;printf(不及格名单:n);while(p!=NULL) if(p-lead.score0lead.score1lead.score2) printf(t);printf(%-10s,);printf(n); p=p-next;该功能的实现是通过比较每个学生各科的成绩,如果有成绩等于60分的,则输出该学生的名字。2.2.7修改记录void xiugaijilu(struct student *head,struct student *stud)/修改记录;struct student *p;int n=0;p=head;while(p!=NULL) if(p-lead.num=stud-lead.num) p-lead=stud-lead; printf(修改成功n); n=1; p=NULL; else p=p-next; if(n=0) printf(该记录不存在,请使用插入功能n);该功能是通过输入学号找到记录该学生信息的结点,再修改该结点的信息,从而达到修改的功能。2.2.8删除记录struct student *del(struct student *head,long num)/删除结点; struct student *p1,*p2;if(head=NULL)printf(nlist null!n);return(head);p1=head;while(num!=p1-lead.num&p1-next!=NULL)p2=p1;p1=p1-next;if(num=p1-lead.num)if(p1=head)head=p1-next;else p2-next=p1-next;printf(delete:%ldn,num);else printf(%ld not been found!n,num);return(head); 该功能的实现是先将文件中的信息写入内存,构成一个链表,接着通过学号找到要删除的结点,并将其删除,再将链表中的信息写入文件,从而实现删除的功能。2.2.9插入记录struct student *insert(struct student *head,struct student *stud)/插入结点;struct student *p0,*p1,*p2; p1=head;p0=stud;if(head=NULL)head=p0;p0-next=NULL;elsewhile(p0-lead.nump1-lead.num)&(p1-next!=NULL)p2=p1;p1=p1-next;if(p0-lead.numlead.num)if(head=p1) head=p0;else p2-next=p0;p0-next=p1; elsep1-next=p0;p0-next=NULL; return(head); 该功能跟删除功能类似,都是通过改变结点来实现功能;只不过这里是增加一个结点。2.2.10成绩输出void print(struct student *head)/打印输出; struct student *p;p=head;printf(nNow,These records are:nnn);printf(No. Name 语文成绩 数学成绩 英语成绩 平均分n);if(head!=NULL)while(p!=NULL)printf(%d %4s %10f %10f %10f %10fn,p-lead.num,,p-lead.score0,p-lead.score1,p-lead.score2,p-lead.aver);p=p-next; else printf(No record); 该功能是通过文件输出,返回hea

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论