C语言学生管理系统链表.pdf

上传人:zh****71 文档编号:126719045 上传时间:2020-03-27 格式:PDF 页数:24 大小:23.36KB
返回 下载 相关 举报
C语言学生管理系统链表.pdf_第1页
第1页 / 共24页
C语言学生管理系统链表.pdf_第2页
第2页 / 共24页
亲,该文档总共24页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《C语言学生管理系统链表.pdf》由会员分享,可在线阅读,更多相关《C语言学生管理系统链表.pdf(24页珍藏版)》请在金锄头文库上搜索。

1、学生管理系统 define CRT SECURE NO WARNINGS include include include voidAppendNode longlong studentID char studentName 10 char studentSex 4 int score 4 添加数据 voidDisplayNode structlink head 显示数据 voidInsertNode longlong studentID char studentName 10 char studentSex 4 int score 4 插入一条数据 按总分的从大到小排序 voidInsertN

2、odeNumber longlong studentID char studentName 10 char studentSex 4 int score 4 按学号的从小到大排序 voidNumberSorting int flag 按从大到小对数据进行排序 1 对总分 进行排序 2 对学号进行排序 voidDeleteNodeID 输入学号删除 voidDeleteNodeName 输入学号删除 voidDeleteMemory structlink head 删除聊表所占用的内存 voidSave 保存数据 voidOpen 打开数据 voidFindID 按学号查找学生 voidFind

3、Name 按姓名查找学生 voidMenu typedefstructstudent longlongstudentID charstudentName 10 charstudentSex 4 intscore 4 STU structlink STU student structlink next structlink head NULL 保存输入的学生信息数据 structlink head1 NULL 保存排序后的学生信息数据 intmain longlongstudentID charstudentName 10 charstudentSex 4 intscore 4 定义要输入学生信

4、息的变量 charc intmenu 保存要进行的选项 Open while 1 system pause Menu printf 请输入要进行的操作 scanf d switch menu case 0 exit 0 break case 1 printf 请输入 Y或y来添加数据 n scanf c while c y c Y printf 请输入学生学号 scanf lld printf 请输入学生姓名 scanf s printf 请输入学生性别 scanf s inti 0 printf 请分别输入学生四门课的成绩 for i 0 inext NULL pr pr next pr n

5、ext p p student studentID studentID strcpy p student studentName studentName strcpy p student studentSex studentSex p student score 0 score 0 p student score 1 score 1 p student score 2 score 2 p student score 3 score 3 p next NULL return voidNumberSorting intflag structlink p head structlink p1 hea

6、d1 intsum 0 if p NULL printf 没有数据 无法排序 return while p NULL switch flag case 1 InsertNode p student studentID p student studentName p student studentSex p student score break case 2 InsertNodeNumber p student studentID p student studentName p student studentSex p student score break default printf 程序

7、异常 请重试 break p p next DisplayNode head1 voidDisplayNode structlink head structlink p head if p NULL return printf lld p student studentID printf 10s p student studentName printf 5s p student studentSex inti 0 for i 0 istudent score i printf n DisplayNode p next voidDeleteMemory structlink head struc

8、tlink p head pr NULL while p NULL pr p p p next free pr voidInsertNodeNumber longlongstudentID charstudentName 10 charstudentSex 4 intscore 4 structlink pr head1 p head1 temp NULL p structlink malloc sizeof structlink if p NULL printf 内存申请失败 return p next NULL p student studentID studentID strcpy p

9、student studentName studentName strcpy p student studentSex studentSex p student score 0 score 0 p student score 1 score 1 p student score 2 score 2 p student score 3 score 3 if head1 NULL head1 p else while pr student studentIDnext NULL temp pr pr pr next if pr student studentID studentID if pr hea

10、d1 p next head1 head1 p else pr temp p next pr next pr next p else pr next p return voidInsertNode longlongstudentID charstudentName 10 char studentSex 4 intscore 4 structlink pr head1 p head1 temp NULL intsum sum1 p structlink malloc sizeof structlink if p NULL printf 内存申请失败 return p next NULL p st

11、udent studentID studentID strcpy p student studentName studentName strcpy p student studentSex studentSex p student score 0 score 0 p student score 1 score 1 p student score 2 score 2 p student score 3 score 3 sum p student score 0 p student score 1 p student score 2 p student score 3 if head1 NULL

12、head1 p else sum1 pr student score 0 pr student score 1 pr student score 2 pr student score 3 while sum1 sum pr pr next sum1 pr student score 0 pr student score 1 pr student score 2 pr student score 3 if sum1 next head1 head1 p else pr temp p next pr next pr next p else pr next p return voidDeleteNo

13、deID 输入学号删除 structlink p head pr head longlongstudentID 0 if head NULL printf 对不起 没有数据可以删除 return printf 请输入你要删除的学生的学号 scanf s studentID while studentID p student studentID p p next if studentID p student studentID if p head head p next else pr next p next free p else printf 你要查找的这个数据未找到 return void

14、DeleteNodeName 输入姓名删除 structlink p head pr head charstudentName 10 if head NULL printf 对不起 没有数据可以删除 return printf 请输入你要删除的学生的姓名 scanf s studentName while 0 strcmp studentName p student studentName p p next if 0 strcmp studentName p student studentName if p head head p next else pr next p next free p

15、 else printf 你要查找的这个数据未找到 return voidSave 保存链表中的数据 FILE fp structlink p head if fp fopen demo txt w NULL printf 打开文件失败 return while p NULL fprintf fp 20lld 10s 5s 4d 4d 4d 4d p student studentID p student studentName p student studentSex p student score 0 p student score 1 p student score 2 p studen

16、t score 3 p p next fclose fp return voidOpen 将文件中获得的数据写入到链表中 longlongstudentID charstudentName 10 charstudentSex 4 intscore 4 FILE fp charc if fp fopen demo txt r NULL printf 文件打开失败 return while c fgetc fp EOF fscanf fp 20lld fscanf fp 10s studentName fscanf fp 5s studentSex fscanf fp 4d fscanf fp 4d fscanf fp 4d fscanf fp 4d AppendNode studentID studentName studentSex score fclose fp voidFindID structlink p head longlongstudentID 0 if head NULL printf 没有数据查找 return printf 请输入你要查找的学生的学号 scanf ll

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

最新文档


当前位置:首页 > 商业/管理/HR > 其它文档

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