C语言程序设计-基于链表的学生成绩管理系统 (2)

时光清浅 分享 2020-06-22 下载文档

华北科技学院计算机系综合性实验报告 { struct xs*p; p=hd->next; if(p!=NULL) { printf(\ 数据显示\\n\ printf(\ printf(\ 学号 姓名 高数 英语 物理 平均分\\n\ printf(\ while(p!=NULL) { printf(\ printf(\ printf(\ printf(\ printf(\ printf(\ p=p->next; } printf(\ printf(\ 链表显示完毕,请按任意键继续!\\n\ getch(); } else printf(\ 当前链表为空,请先读取文件或创建链表!\\n 按任意键继续!\\n \ } ?查询记录源代码 void menu() { system(\ 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\ printf(\ 请选择操作(1-5:\

第 5 页

华北科技学院计算机系综合性实验报告 } ?源程序 #include\#include\#include #include\struct xs { int xh; char xm[20]; 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; free(p); } } void create(struct xs *hd) { int xh,gs,yy,wl,i; char xm[20]; struct xs *p; fr(hd); printf(\ 请输入学生个数:\ scanf(\ for(i=0;i

第 6 页

华北科技学院计算机系综合性实验报告 scanf(\ printf(\ 姓名:\ scanf(\ printf(\ 高数:\ scanf(\ printf(\ 英语:\ scanf(\ printf(\ 物理:\ scanf(\ p=(struct xs *)malloc(sizeof(struct xs)); p->xh=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 save(struct xs *hd) { if(hd->next!=NULL) { struct xs *p=hd->next; int i; FILE *fp; fp=fopen(\ fprintf(fp,\ for(i=0;inext; } fclose(fp); printf(\ 保存文件完毕,请按任意键继续!\\n \ getch(); } else { printf(\ 当前链表为空,不需要保存,请按任意键继续!\\n \

第 7 页

华北科技学院计算机系综合性实验报告 getch(); } } void read(struct xs *hd) { int i; struct xs *p; FILE *fp; fr(hd); fp=fopen(\ fscanf(fp,\ for(i=0;inext=hd->next; hd->next=p; } fclose(fp); printf(\ 读取文件完毕,请按任意键继续!\\n \ getch(); } void print(struct xs *hd) { struct xs*p; p=hd->next; if(p!=NULL) { printf(\ 数据显示\\n\ printf(\ printf(\ 学号 姓名 高数 英语 物理 平均分\\n\ printf(\ while(p!=NULL) { printf(\ printf(\ printf(\ printf(\ printf(\ printf(\ p=p->next; } printf(\

第 8 页

华北科技学院计算机系综合性实验报告 printf(\ 链表显示完毕,请按任意键继续!\\n\ getch(); } else printf(\ 当前链表为空,请先读取文件或创建链表!\\n 按任意键继续!\\n \ } void menu() { system(\ 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\ printf(\ 请选择操作(1-5:\ } void main() { int xz=0; struct xs *head; head=init(); while(xz!=5) { menu(); scanf(\ switch(xz) { case 1: create(head); break; case 2: print(head); break; case 3: save(head); break; case 4:

第 9 页


C语言程序设计-基于链表的学生成绩管理系统 (2).doc 将本文的Word文档下载到电脑

下一篇:思想道德修养与法律基础试题库

相关推荐
相关阅读
本类排行
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 7

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xxxxxx QQ:xxxxxx