C语言程序设计 基于链表的学生成绩管理系统_第1页
C语言程序设计 基于链表的学生成绩管理系统_第2页
C语言程序设计 基于链表的学生成绩管理系统_第3页
C语言程序设计 基于链表的学生成绩管理系统_第4页
C语言程序设计 基于链表的学生成绩管理系统_第5页
已阅读5页,还剩17页未读 继续免费阅读

下载本文档

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

文档简介

1、华北科技学院计算机系综合性实验 实验报告 课程名称 语言程序设计 实验学期 2011 至 2012 学年第 学期 计算机系 学生所在系部 年级2011 专业班级 计算机科学与技术B-111 学号 学生姓名 任课教师 实验成绩 计算机系制 实验报告须知 1、 学生上交实验报告时,必须为打印稿( A4 纸)。页面空间不够,可以顺延。 2、 学生应该填写的内容包括:封面相关栏目、实验地点、时间、目的、设备环境、 内容、结果及分析等。 3、 教师应该填写的内容包括:实验成绩、教师评价等。 4、 教师根据本课程的综合性实验指导单中实验内容的要求,评定学生的综合 性实验成绩;要求在该课程期末考试前将实验报

2、告交给任课教师。综合性实验 中,所涉及的程序,文档等在交实验报告前,拷贝给任课教师。任课教师统一 刻录成光盘,与该课程的期末考试成绩一同上交到系里存档。 5、 未尽事宜,请参考该课程的实验大纲和教学大纲。 c语言程序设计课程综合性实验报告 开课实验室:基础五 2012 实验题目 基于链表的学生成绩管理系统 、实验目的 1、掌握链表的创建、遍历显示和清除; 2、掌握链表数据的文件保存、读取; 、设备与环境 微型计算机、VC+ 三、实验内容 1、定义结构体,创建链表 struct xsnode int xh; char xm15; in t gs; int yy; int wl; struct x

3、snode *n ext; ; 2、根据以上链表结点结构,实现以下功能 a 、学生学号、姓名、各门成绩的录入; b、链表数据显示及清除; c 、链表数据的文件保存与读取; 四、实验结果及分析 1、运行结果 主菜单 数据显示 2、源程序 主函数 void mai n() int xz=0; struct xs *head; head=in it(); while(xz!=5) menu(); sea nf(%d, switch(xz) ease 1: ereate(head); break; ease 2: prin t(head); break; ease 3: save(head); bre

4、ak; ease 4: read(head); break; ease 5: prin tf(n 系统退出,拜拜!n); break; default: prin tf(n 选择错误,请按任意键选择!n); geteh(); break; fr(head); free(head); 数据录入源代码 void create(struct xs *hd) i nt xh,gs,yy,wl,i; char xm20; struct xs *p; fr(hd); printf(n请输入学生个数:); sca nf(%d, f or(i=0;i vnu m;i+) printf(请输入 d 个学生 of

5、 %dn,i+1, num); prin tf(学号:); scan f(%d, prin tf(姓名:); scan f(%s,xm); prin tf(高数:); scan f(%d, prin tf(英语:); scan f(%d, prin tf(物理:); scan f(%d, p=(struct xs *)malloc(sizeof(struct xs); p-xh=xh; strc py(p-xm,xm); p-gs=gs; p-yy=yy; p-wl=wl; p-n ext=hd-n ext; hd-n ext=p; 录入数据完毕,请按任意键继续!n ); printf( ge

6、tch(); 添加记录源代码 void prin t(struct xs *hd) struct xs* p; p=hd-n ext; if(p!=NULL) prin tf(n数据显示 n); prin tf(*n); printf( 学号 姓名 高数 英语物理平均分n); prin tf(*n); while( p!=NULL) prin tf(%4d ,p-xh); prin tf(%10s ,p-xm); prin tf(%8d, p-gs); prin tf(%7d, p-yy); prin tf(%6d, p-wl); prin tf(%n,( p-wl+p-wl+p-wl)/;

7、p=p-n ext; *n); 链表显示完毕,请按任意键继续!n); prin tf( printf( getch(); else 当前链表为空,请先读取文件或创建链表!n按任意键继 prin tf(n 续!n ); 查询记录源代码 void menu() system(cls); printf( printf( printf( printf( prin tf( *n); * 学生成绩管理系统*n); *n); prin tf( * 1- 创建链表 *n); prin tf( * 2- 数据显示 *n); prin tf( * 3- 保存文件 *n); prin tf( * 4- 读取文件 *

8、n); prin tf( * 5- 系统退出 *n); prin tf( *n); prin tf( 请选择操作(1-5:); * jb11-1 31宋洁 2012-7-3*n); *n); 源程序 #i nclude #i nclude #in clude #i nclude struct xs i nt xh; char xm20; i nt gs,yy,wl; struct xs *n ext; ; int num=0; struct xs *in it() struct xs* hd; hd=(struct xs *)malloc(sizeof(struct xs); hd- next

9、=NULL; retur n hd; void fr(struct xs *hd) struct xs *p; p=hd-n ext; while(hd- next!=NULL) p=hd-n ext; hd-n ext=p-n ext; free( p); void create(struct xs *hd) i nt xh,gs,yy,wl,i; char xm20; struct xs *p; fr(hd); printf(n请输入学生个数:); sca nf(%d, f or(i=0;i vnu m;i+) printf(请输入 d 个学生 of %dn,i+1, num); prin

10、 tf( 学号:); scan f(%d, prin tf(姓名:); scan f(%s,xm); prin tf(高数:); scan f(%d, prin tf(英语:); scan f(%d, prin tf(物理:); scan f(%d, p=(struct xs *)malloc(sizeof(struct xs); p-xh=xh; strc py(p-xm,xm); p-gs=gs; p-yy=yy; p-wl=wl; p-n ext=hd-n ext; hd-n ext=p; printf( getch(); void save(struct xs *hd) if(hd-

11、next!=NULL) struct xs *p=hd-n ext; int i; FILE *fp; fp=fopen (,w); fprin tf(fp,%3dn, nu m); for(i=0;i vnu m;i+) 录入数据完毕,请按任意键继续!n ); fprin tf(fp,%3d %12s %3d %3d %3dn ,p-xh, p-xm, p-gs, p-yy, p-wl); p=p-n ext; fclose(fp); prin tf(n getch(); else prin tf(n 保存文件完毕,请按任意键继续!n ); 当前链表为空,不需要保存,请按任意键继续!n );

12、 getch(); void read(struct xs *hd) int i; struct xs *p; FILE *fp; fr(hd); fp=fo pen( ,r); fscan f(fp,%3dn, for(i=0;i vnu m;i+) p=(struct xs *)malloc(sizeof(struct xs); fscan f(fp,%3d %12s %3d %3d %3dn, p-xh, p-xm, p-gs, p-yy, p-wl); p-n ext=hd-n ext; hd-n ext=p; fclose(fp); 读取文件完毕,请按任意键继续!n); prin t

13、f(n getch(); void prin t(struct xs *hd) struct xs* p; p=hd-n ext; if(p!=NULL) printf(n数据显示 n); prin tf(*n); printf( 学号 姓名 高数 英语物理平均分n); prin tf(*n); while( p!=NULL) prin tf(%4d ,p-xh); prin tf(%10s, p-xm); prin tf(%8d, p-gs); prin tf(%7d, p-yy); prin tf(%6d, p-wl); prin tf(%n,( p-wl+p-wl+p-wl)/; p=p

14、-n ext; prin tf(*n); printf( geteh(); else prin tf(n 继续!n ); void menu() system(els); printf( printf( printf( printf( prin tf( 链表显示完毕,请按任意键继续!n); 当前链表为空,请先读取文件或创建链表!n按任意键 *n); * 学生成绩管理系统*n); *n); prin tf( * 1- 创建链表 *n); prin tf( * 2- 数据显示 *n); prin tf( * 3- 保存文件 *n); prin tf( * 4- 读取文件 *n); prin tf(

15、 * 5- 系统退出 *n); prin tf( *n); prin tf( 请选择操作(1-5:); * jb11-1 31宋洁 2012-7-3*n); *n); void mai n() i nt xz=0; struct xs *head; head=in it(); while(xz!=5) menu(); sea nf(%d, switch(xz) ease 1: ereate(head); break; ease 2: prin t(head); break; ease 3: save(head); break; ease 4: read(head); break; case 5

16、: prin tf(n break; default: prin tf(n getchO; break; 系统退出,拜拜!n ); 选择错误,请按任意键选择!n); fr(head); free(head); 3、试验收获 通过这次试验,我掌握了链表的创建、遍历显示和清除功能,掌握了链表数据的文 件保存、读取,能够熟练的使用VC+对C程序有了更深的了解。 教 师 评 价 评定项目 A B C D 评定项目 A B C D 算法正确 界面美观,布局合理 程序结构合理 操作熟练 语法、语义正 确 解析完整 实验结果正确 文字流畅 报告规范 题解正确 其他: 评价教师签名: 年 月曰 代码: #in

17、clude #include #include #include struct xs int xh; char xm20; int gs,yy,wl; struct xs *next; ; int num=0; struct xs *init() struct xs* hd; hd=(struct xs *)malloc(sizeof(struct xs); hd-next=NULL; return hd; void fr(struct xs *hd) struct xs *p; p=hd-next; while(hd-next!=NULL) p=hd-next; hd-next=p-next

18、; free(p); void create(struct xs *hd) int xh,gs,yy,wl,i; char xm20; struct xs *p; fr(hd); printf(n 请输入学生个数 :); scanf(%d, for(i=0;ixh=xh; strcpy(p-xm,xm); p-gs=gs; p-yy=yy; p-wl=wl; printf(录入数据完毕,请按任意键继续 !n ); p-next=hd-next; hd-next=p; getch(); void save(struct xs *hd) if(hd-next!=NULL) struct xs *p

19、=hd-next; int i; FILE *fp; fp=fopen(,w); fprintf(fp,%3dn,num); for(i=0;ixh,p-xm,p-gs,p-yy,p-wl); p=p-next; fclose(fp); printf(n 保存文件完毕,请按任意键继续 !n ); getch(); else printf(n 当前链表为空,不需要保存,请按任意键继续 !n ); getch(); void read(struct xs *hd) int i; struct xs *p; FILE *fp; fr(hd); fp=fopen(,r); fscanf(fp,%3dn

20、, for(i=0;ixh,p-xm,p-gs,p-yy,p-wl); p-next=hd-next; hd-next=p; fclose(fp); printf(n 读取文件完毕,请按任意键继续 !n ); getch(); void print(struct xs *hd) struct xs*p; p=hd-next; if(p!=NULL) printf(n 数据显示 n); printf(*n); printf( 学号 姓名 高数 英语 物理 平均分 n); printf(*n); printf(%4d ,p-xh); while(p!=NULL) printf(%10s,p-xm); printf(%8d,p-gs); printf(%7d,p-yy); printf(%6d,p-wl); printf(%n,(p-wl+p-wl+p-wl)/; p=p-next; printf(

温馨提示

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

评论

0/150

提交评论