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

下载本文档

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

文档简介

.z......资料....华北科技学院计算机系综合性实验实验报告课程名称C语言程序设计实验学期2011至2012学年第二学期学生所在系部计算机系年级2011专业班级计算机科学与技术B-111学生**任课教师实验成绩计算机系制实验报告须知学生上交实验报告时,必须为打印稿(A4纸)。页面空间不够,可以顺延。学生应该填写的容包括:封面相关栏目、实验地点、时间、目的、设备环境、容、结果及分析等。教师应该填写的容包括:实验成绩、教师评价等。教师根据本课程的《综合性实验指导单》中实验容的要求,评定学生的综合性实验成绩;要求在该课程期末考试前将实验报告交给任课教师。综合性实验中,所涉及的程序,文档等在交实验报告前,拷贝给任课教师。任课教师统一刻录成光盘,与该课程的期末考试成绩一同上交到系里存档。未尽事宜,请参考该课程的实验大纲和教学大纲。《C语言程序设计》课程综合性实验报告开课实验室:基础五2012年7月6日实验题目基于链表的学生成绩管理系统一、实验目的1、掌握链表的创建、遍历显示和清除;2、掌握链表数据的文件保存、读取;二、设备与环境微型计算机、VC++6.0三、实验容1、定义结构体,创建链表struct*snode{int*h;char*m[15];intgs;intyy;intwl;struct*snode*ne*t;};2、根据以上链表结点结构,实现以下功能a、学生**、、各门成绩的录入;b、链表数据显示及清除;c、链表数据的文件保存与读取;四、实验结果及分析1、运行结果主菜单数据显示2、源程序主函数voidmain(){int*z=0;struct*s*head;head=init();while(*z!=5){ menu(); scanf("%d",&*z); switch(*z) { case1: create(head); break; case2: print(head); break; case3: save(head); break; case4: read(head); break; case5: printf("\n系统退出,拜拜!\n"); break; default: printf("\n选择错误,请按任意键选择!\n"); getch(); break; }}fr(head);free(head);}数据录入源代码voidcreate(struct*s*hd){ int*h,gs,yy,wl,i; char*m[20]; struct*s*p; fr(hd); printf("\n请输入学生个数:"); scanf("%d",&num); for(i=0;i<num;i++) { printf("请输入%d个学生of%d\n",i+1,num); printf("**:"); scanf("%d",&*h); printf(":"); scanf("%s",*m); printf("高数:"); scanf("%d",&gs); printf("英语:"); scanf("%d",&yy); printf("物理:"); scanf("%d",&wl); p=(struct*s*)malloc(sizeof(struct*s)); p->*h=*h; strcpy(p->*m,*m); p->gs=gs; p->yy=yy; p->wl=wl; p->ne*t=hd->ne*t; hd->ne*t=p; } printf("录入数据完毕,请按任意键继续!\n"); getch();}添加记录源代码 voidprint(struct*s*hd) {struct*s*p; p=hd->ne*t; if(p!=NULL) { printf("\n数据显示\n"); printf("**********************************************\n"); printf("**高数英语物理平均分\n"); printf("**********************************************\n"); while(p!=NULL) { printf("%4d",p->*h); printf("%10s",p->*m); printf("%8d",p->gs); printf("%7d",p->yy); printf("%6d",p->wl); printf("%8.2f\n",(p->wl+p->wl+p->wl)/3.0); p=p->ne*t; } printf("**********************************************\n"); printf("链表显示完毕,请按任意键继续!\n");getch(); } else printf("\n当前链表为空,请先读取文件或创建链表!\n按任意键继续!\n"); }查询记录源代码voidmenu(){ system("cls"); printf("****************************************\n"); printf("*学生成绩管理系统(1.0)*\n"); printf("****************************************\n"); printf("*11-131宋洁2012-7-3*\n"); printf("****************************************\n"); printf("*1-创建链表*\n"); printf("*2-数据显示*\n"); printf("*3-保存文件*\n"); printf("*4-读取文件*\n"); printf("*5-系统退出*\n"); printf("****************************************\n"); printf("请选择操作(1-5:"); }源程序*include"stdio.h"*include"stdlib.h"*include<string.h>*include"conio.h"struct*s{ int*h; char*m[20]; intgs,yy,wl; struct*s*ne*t;};intnum=0;struct*s*init(){ struct*s*hd; hd=(struct*s*)malloc(sizeof(struct*s)); hd->ne*t=NULL; returnhd;}voidfr(struct*s*hd){ struct*s*p;p=hd->ne*t;while(hd->ne*t!=NULL) { p=hd->ne*t; hd->ne*t=p->ne*t; free(p); }}voidcreate(struct*s*hd){ int*h,gs,yy,wl,i; char*m[20]; struct*s*p; fr(hd); printf("\n请输入学生个数:"); scanf("%d",&num); for(i=0;i<num;i++) { printf("请输入%d个学生of%d\n",i+1,num); printf("**:"); scanf("%d",&*h); printf(":"); scanf("%s",*m); printf("高数:"); scanf("%d",&gs); printf("英语:"); scanf("%d",&yy); printf("物理:"); scanf("%d",&wl); p=(struct*s*)malloc(sizeof(struct*s)); p->*h=*h; strcpy(p->*m,*m); p->gs=gs; p->yy=yy; p->wl=wl; p->ne*t=hd->ne*t; hd->ne*t=p; } printf("录入数据完毕,请按任意键继续!\n"); getch();} voidsave(struct*s*hd) { if(hd->ne*t!=NULL) { struct*s*p=hd->ne*t; inti; FILE*fp; fp=fopen("yh.t*t","w"); fprintf(fp,"%3d\n",num); for(i=0;i<num;i++) { fprintf(fp,"%3d%12s%3d%3d%3d\n",p->*h,p->*m,p->gs,p->yy,p->wl); p=p->ne*t; } fclose(fp);printf("\n保存文件完毕,请按任意键继续!\n"); getch(); } else { printf("\n当前链表为空,不需要保存,请按任意键继续!\n"); getch(); } } voidread(struct*s*hd) { inti; struct*s*p; FILE*fp; fr(hd); fp=fopen("yh.t*t","r"); fscanf(fp,"%3d\n",&num); for(i=0;i<num;i++) {p=(struct*s*)malloc(sizeof(struct*s));fscanf(fp,"%3d%12s%3d%3d%3d\n",p->*h,p->*m,p->gs,p->yy,p->wl); p->ne*t=hd->ne*t; hd->ne*t=p; } fclose(fp); printf("\n读取文件完毕,请按任意键继续!\n"); getch(); } voidprint(struct*s*hd) {struct*s*p; p=hd->ne*t; if(p!=NULL) { printf("\n数据显示\n"); printf("**********************************************\n"); printf("**高数英语物理平均分\n"); printf("**********************************************\n"); while(p!=NULL) { printf("%4d",p->*h); printf("%10s",p->*m); printf("%8d",p->gs); printf("%7d",p->yy); printf("%6d",p->wl); printf("%8.2f\n",(p->wl+p->wl+p->wl)/3.0); p=p->ne*t; } printf("**********************************************\n"); printf("链表显示完毕,请按任意键继续!\n");getch(); } else printf("\n当前链表为空,请先读取文件或创建链表!\n按任意键继续!\n"); }voidmenu(){ system("cls"); printf("****************************************\n"); printf("*学生成绩管理系统(1.0)*\n"); printf("****************************************\n"); printf("*11-131宋洁2012-7-3*\n"); printf("****************************************\n"); printf("*1-创建链表*\n"); printf("*2-数据显示*\n"); printf("*3-保存文件*\n"); printf("*4-读取文件*\n"); printf("*5-系统退出*\n"); printf("****************************************\n"); printf("请选择操作(1-5:"); }voidmain(){ int*z=0;struct*s*head;head=init();while(*z!=5){ menu(); scanf("%d",&*z); switch(*z) { case1: create(head); break; case2: print(head); break; case3: save(head); break; case4: read(head); break; case5: printf("\n系统退出,拜拜!\n"); break; default: printf("\n选择错误,请按任意键选择!\n"); getch(); break; }}fr(head);free(head);}3、试验收获通过这次试验,我掌握了链表的创建、遍历显示和清除功能,掌握了链表数据的文件保存、读取,能够熟练的使用VC++6.0,对C程序有了更深的了解。教师评价评定项目ABCD评定项目ABCD算确界面美观,布局合理程序结构合理操作熟练语法、语义正确解析完整实验结果正确文字流畅报告规题解正确其他:评价教师签名:年月日代码:*include"stdio.h"*include"stdlib.h"*include<string.h>*include"conio.h"struct*s{ int*h; char*m[20]; intgs,yy,wl; struct*s*ne*t;};intnum=0;struct*s*init(){ struct*s*hd; hd=(struct*s*)malloc(sizeof(struct*s)); hd->ne*t=NULL; returnhd;}voidfr(struct*s*hd){ struct*s*p;p=hd->ne*t;while(hd->ne*t!=NULL) { p=hd->ne*t; hd->ne*t=p->ne*t; free(p); }}voidcreate(struct*s*hd){ int*h,gs,yy,wl,i; char*m[20]; struct*s*p; fr(hd); printf("\n请输入学生个数:"); scanf("%d",&num); for(i=0;i<num;i++) { printf("请输入%d个学生of%d\n",i+1,num); printf("**:"); scanf("%d",&*h); printf(":"); scanf("%s",*m); printf("高数:"); scanf("%d",&gs); printf("英语:"); scanf("%d",&yy); printf("物理:"); scanf("%d",&wl); p=(struct*s*)malloc(sizeof(struct*s)); p->*h=*h; strcpy(p->*m,*m); p->gs=gs; p->yy=yy; p->wl=wl; p->ne*t=hd->ne*t; hd->ne*t=p; } printf("录入数据完毕,请按任意键继续!\n"); getch();} voidsave(struct*s*hd) { if(hd->ne*t!=NULL) { struct*s*p=hd->ne*t; inti; FILE*fp; fp=fopen("yh.t*t","w"); fprintf(fp,"%3d\n",num); for(i=0;i<num;i++) { fprintf(fp,"%3d%12s%3d%3d%3d\n",p->*h,p->*m,p->gs,p->yy,p->wl); p=p->ne*t; } fclose(fp); printf("\n保存文件完毕,请按任意键继续!\n"); getch(); } else { printf("\n当前链表为空,不需要保存,请按任意键继续!\n"); getch(); } } voidread(struct*s*hd) { inti; struct*s*p; FILE*fp; fr(hd); fp=fopen("yh.t*t","r"); fscanf(fp,"%3d\n",&num); for(i=0;i<num;i++) {p=(struct*s*)malloc(sizeof(struct*s));fscanf(fp,"%3d%12s%3d%3d%3d\n",p->*h,p->*m,p->gs,p->yy,p->wl); p->ne*t=hd->ne*t; hd->ne*t=p; } fclose(fp); printf("\n读取文件完毕,请按任意键继续!\n"); getch(); } voidprint(struct*s*hd) {struct*s*p; p=hd->ne*t; if(p!=NULL) { printf("\n数据显示\n"); printf("**********************************************\n"); printf("**高数英语物理平均分\n"); printf("**********************************************\n"); while(p!=NULL) { printf("%4d",p->*h); printf("%10s",p->*m); printf("%8d",p->gs); printf("%7d",p->yy); printf("%6d",p->wl); printf("%8.2f\n",(p->wl+p->wl+p->wl)/3.0); p=p->ne*t; } printf("**********************************************\n"); printf("链表显示完毕,请按任意键继续!\n");getch(); } else printf("\n当前链表为空,请先读取文件或创建链表!\n按任意键继续!\n"); }voidmenu(){ system("cls"); printf("****************************************\n

温馨提示

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

评论

0/150

提交评论