c语言程序设计-基于链表学生成绩管理系统

上传人:第*** 文档编号:55264277 上传时间:2018-09-26 格式:DOC 页数:18 大小:85KB
返回 下载 相关 举报
c语言程序设计-基于链表学生成绩管理系统_第1页
第1页 / 共18页
c语言程序设计-基于链表学生成绩管理系统_第2页
第2页 / 共18页
c语言程序设计-基于链表学生成绩管理系统_第3页
第3页 / 共18页
c语言程序设计-基于链表学生成绩管理系统_第4页
第4页 / 共18页
c语言程序设计-基于链表学生成绩管理系统_第5页
第5页 / 共18页
点击查看更多>>
资源描述

《c语言程序设计-基于链表学生成绩管理系统》由会员分享,可在线阅读,更多相关《c语言程序设计-基于链表学生成绩管理系统(18页珍藏版)》请在金锄头文库上搜索。

1、华北科技学院计算机系综合性实验华北科技学院计算机系综合性实验实实 验验 报报 告告 课程名称课程名称 C C 语言程序设计语言程序设计 实验学期实验学期 20112011 至至 20122012 学年学年 第第 二二 学期学期 学生所在系部学生所在系部 计算机系计算机系 年级年级 20112011 专业班级专业班级 计算机科学与技术计算机科学与技术 B-111B-111 学生姓名学生姓名 学号学号 任课教师任课教师 实验成绩实验成绩 计算机系制计算机系制实验报告须知实验报告须知1、 学生上交实验报告时,必须为打印稿(A4 纸) 。页面空间不够,可以顺延。2、 学生应该填写的内容包括:封面相关栏

2、目、实验地点、时间、目的、设备环境、内容、结果及分析等。3、 教师应该填写的内容包括:实验成绩、教师评价等。4、 教师根据本课程的综合性实验指导单中实验内容的要求,评定学生的综合性实验成绩;要求在该课程期末考试前将实验报告交给任课教师。综合性实验中,所涉及的程序,文档等在交实验报告前,拷贝给任课教师。任课教师统一刻录成光盘,与该课程的期末考试成绩一同上交到系里存档。5、 未尽事宜,请参考该课程的实验大纲和教学大纲。CC 语言程序设计语言程序设计课程综合性实验报告课程综合性实验报告开课实验室:基础五开课实验室:基础五 20122012 年年 7 7 月月 6 6 日日实验题目基于链表的学生成绩管

3、理系统一、实验目的1、掌握链表的创建、遍历显示和清除; 2、掌握链表数据的文件保存、读取;二、设备与环境微型计算机、VC+6.0三、实验内容1、定义结构体,创建链表struct xsnode int xh;char xm15;int gs;int yy;int wl;struct xsnode *next; ;2、根据以上链表结点结构,实现以下功能 a、学生学号、姓名、各门成绩的录入;b、链表数据显示及清除;c、链表数据的文件保存与读取;四、实验结果及分析1、运行结果主菜单数据显示2、源程序主函数 void main() int xz=0;struct xs *head;head=init()

4、;while(xz!=5)menu();scanf(“%d“,switch(xz)case 1:create(head);break; case 2:print(head);break; case 3:save(head);break;case 4:read(head);break;case 5:printf(“n 系统退出,拜拜!n “);break; default: printf(“n 选择错误,请按任意键选择!n “); getch(); break;fr(head);free(head); 数据录入源代码 void create(struct xs *hd) int xh,gs,yy

5、,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;p-next=hd-next; hd-next=p; printf(“ 录入数据完毕,请按任意键继续!n “); getch(); 添加记录源代码 void print(struct xs *hd) struct xs*p; p=hd-next; if(p!=NULL) printf(“n 数据显示n“); printf(“*n“)

6、; printf(“ 学号 姓名 高数 英语 物理 平均分n“); printf(“*n“); while(p!=NULL) printf(“%4d “,p-xh); printf(“%10s“,p-xm); printf(“%8d“,p-gs); printf(“%7d“,p-yy); printf(“%6d“,p-wl); printf(“%8.2fn“,(p-wl+p-wl+p-wl)/3.0); p=p-next; printf(“*n“); printf(“ 链表显示完毕,请按任意键继续!n“);getch(); else printf(“n 当前链表为空,请先读取文件或创建链表!n

7、 按任意键继续!n “); 查询记录源代码 void menu() system(“cls“); printf(“ *n“); printf(“ * 学生成绩管理系统(1.0) *n“); printf(“ *n“); printf(“ * jb11-1 31 宋洁 2012-7-3 *n“); printf(“ *n“); printf(“ * 1-创建链表 *n“); printf(“ * 2-数据显示 *n“); printf(“ * 3-保存文件 *n“); printf(“ * 4-读取文件 *n“); printf(“ * 5-系统退出 *n“); printf(“ *n“); p

8、rintf(“ 请选择操作(1-5:“); 源程序 #include“stdio.h“ #include“stdlib.h“ #include #include“conio.h“ 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

9、=hd-next;while(hd-next!=NULL) p=hd-next; hd-next=p-next; 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;p-next=hd-next; hd-next=p; printf(“ 录入数据完毕,请按任意键继续!n “); getch

10、(); void save(struct xs *hd) if(hd-next!=NULL) struct xs *p=hd-next; int i; FILE *fp; fp=fopen(“yh.txt“,“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 x

11、s *hd) int i; struct xs *p; FILE *fp; fr(hd); fp=fopen(“yh.txt“,“r“); fscanf(fp,“%3dn“, 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“); while(p!=NULL) printf(“%4d “,p-xh); printf(“%10s“,p-xm); printf(“%8d“,p-gs); printf(“%7d“,p-yy); printf(“%6d“,p-wl); printf(“%8.2fn“,(p-wl+p-wl+p-wl)/3.0); p=p-next; printf(“*n“); printf(“ 链表显示完毕,请按任意键继续!n“);getch(); else printf(“n 当前链表为空,请先读取文件或创建链表!

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 办公文档 > 事务文书

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号