C语言课程设计-学生成绩简单管理程序

上传人:lizhe****0001 文档编号:31220099 上传时间:2018-02-06 格式:DOC 页数:8 大小:74KB
返回 下载 相关 举报
C语言课程设计-学生成绩简单管理程序_第1页
第1页 / 共8页
C语言课程设计-学生成绩简单管理程序_第2页
第2页 / 共8页
C语言课程设计-学生成绩简单管理程序_第3页
第3页 / 共8页
C语言课程设计-学生成绩简单管理程序_第4页
第4页 / 共8页
C语言课程设计-学生成绩简单管理程序_第5页
第5页 / 共8页
点击查看更多>>
资源描述

《C语言课程设计-学生成绩简单管理程序》由会员分享,可在线阅读,更多相关《C语言课程设计-学生成绩简单管理程序(8页珍藏版)》请在金锄头文库上搜索。

1、 C 语言课程设计报告学生成绩简单管理程序一、程序的主要功能用单向链表结构实现简单的学生成绩管理功能,要求具有链表建立、链表输出、结点有序插入、节电删除、数据查询等功能。各项菜单功能:(1)Creat List(建立有序单向链表)从键盘上一次输入一个学生的姓名和成绩,以姓名为序建立有序链表。插入一条记录后,显示提示信息:确认是否输入下一条记录,如确认,继续输入,否着推出输入功能。(2)Display All Record(显示所有结点记录)按顺序显示链表中所有记录,每屏显示 10 条记录。每显示 10 条,按键继续显示下一屏。(3)Insert a Record(插入一条结点记录)在以姓名为序

2、排列的链表中插入一条记录,插入后,链表仍然有序。输出成功信息。(4)Delete a Record(按姓名查找,删除一条结点记录)输入待删除记录的姓名,显示提示信息,让用户再次确认是否要删除。确认后,将该姓名的记录删除。 (5) Query(查找并显示一个结点记录)输入姓名,查找该记录,并显示该学生成绩。(6)Add Records from a Text File (从正文文件添加数据到链表中)用户可提前建立一个正文文件 data.txt,存放多个带加入的记录。提示输入正文的文件名,然后从该文件中一次性加入多条学生记录。文件 data.txt 格式如下:2 /*表示带添加的记录数*/Wang

3、Xiao 95 /*下面每行为姓名和成绩 */LiuLin 87(7)Write to a Text File将链表中的全部记录写入文件 records.txt,要求文件格式和 data.txt 相同。新增菜单功能:(8)Reverse List将链表中的所有结点逆序存放。(9) Delete the Same Record删除相同姓名的记录。(0) Quit退出系统并释放链表存储空间。二、主要问题及解决方法:在写程序中遇到的问题是:开始时无法正确完成“确认后再继续”的问题再后来写附加程序对链表逆序有些疑惑。面对遇到的问题我先自己认真耐心的修改,严格按照老师说的各个功能分步测试方法,解决了其中

4、的大多数问题,对遗留下来的以和同学交流探讨与问老师相结合的方式来达到彻底的解决。心得体会:完成之后程序运行到一半会停止,不得不对 300 多行的程序进行单步调试,解决了很多问题之后,发现编程需要非常严谨的态度和足够的耐心,否则就会因为一些问题而卡住甚至放弃。当然在整个过程中,同学帮助解决了许多自己没有意识到得错误,换一个角度,才能发现问题吧。三、源程序及注释:#include /*库函数调用 */#include #include #include #include struct stud /*定义一个结构体类型 struct stud*/char name20;float score;str

5、uct stud *next;typedef struct stud Student; /*用 Student 替代 struct stud*/int menu_select(); /*全体函数的外部申明*/Student *Create();void Display(Student *);Student *Insert(Student *,Student *);Student *Insert_a_Record(Student *);Student *Delete(Student *,char *);Student *Delete_a_Record(Student *);Student *Qu

6、ery(Student *,char *);void Query_a_record(Student *);Student *AddfromText(Student *,char *);void WritetoText(Student *,char *);void Quit(Student *);Student *Reverse(Student *);Student *DeleteSame(Student*);int n; /*定义一个全局变量*/main()Student *head=NULL ;char filename20; /*定义一个字符数组*/while (1)switch (men

7、u_select() /*调用 menu select 函数输出菜单*/case 1:printf(Execution of Create Listn);head=Create(); /*输入 1 调用 Creat List 函数*/system(pause);break;case 2:printf(Execution of Display All Recordn);Display(head); /* 输入 2 调用 Display All Record 函数*/system(pause);break;case 3:printf(Execution of Insert a Recordn);h

8、ead=Insert_a_Record(head); /*输入 3 调用 Insert a Record 函数*/system(pause);break;case 4:printf(Execution of Delete a Recordn);head=Delete_a_Record(head); /*输入 4 调用 Delete a Record 函数*/system(pause);break;case 5:printf(Execution of Queryn); /*输入 5 调用 Query 函数*/Query_a_record(head);system(pause);break;cas

9、e 6:printf(Execution of Add Records from a Texl Filen);head=AddfromText(head,filename); /*输入 6 调用 Add Record from asystem(pause); Texl File 函数*/break;case 7:printf(Execution of Write to a Texl Filen);WritetoText(head,filename); /*输入 7 调用 TexlFile 函数 */system(pause);break;case 8:printf(Reverse Listn)

10、; /*输入 8 调用 Reverse 函数*/head=Reverse(head);system(pause);break; case 9:printf(Delete The Same Recordn);head=DeleteSame(head); /*输入 9 调用 Delete The Same Record 函数system(pause); */break;case 0:printf(Execution of Quitn); /*输入 0 调用 Quit 函数*/Quit(head);system(pause);exit(0);int menu_select()int c;dosyst

11、em(cls); /*显示主菜单*/printf(1.Create Listn);printf(2.Display All Recordn);printf(3.Insert a Recordn);printf(4.Delete a Recordn);printf(5.Queryn);printf(6.Add Records from a Texl Filen);printf(7.Write to a Texl Filen);printf(8.Reverse listn);printf(9.Delete the same recordn);printf(0.Quitn);printf(Input

12、 0-9:n);scanf(%d,while (c9);return(c);Student *Create() /*创建有序链表 */Student *p,*head=NULL; /*定义结构体指针*/char b=y; /* 定义一个字符数组*/printf(Create an inceaing list-n);/*如果输入的是 No 结束*/while (b!=n&b!=N) /*如果不是 No 执行循环*/p=(Student*)malloc(sizeof(Student); /*申请存储空间*/printf(please input the name and the score:);s

13、canf(%s%f,p-name, /*将姓名和成绩存入结点*/head=Insert(head,p);printf(Please input a record(if(N or n) exit):);/*输入下一组数据*/getchar();scanf(%c,return(head); /*返回链表头指针*/void Display(Student *head) /*显示所有结点记录*/Student *p; /*定义结构体指针*/int n=0;p=head; /*令 p 为头结点*/printf(Output list:n);while (p!=NULL) /*p 非空执行*/ n+;pr

14、intf(%s:%fn,p-name,p-score);/*输出结点*/p=p-next; /*指向下一个结点*/if (n%10=0&n=10)system(cls);system(pause); /*每输出 10 个暂停一次*/Student *Insert(Student *head,Student *p0)/*结点有序插入*/Student *p1,*p2; /*定义结构体指针*/if (head=NULL) /*如果原链表为空链表*/head=p0;p0-next=NULL;return(head); /*返回链表头指针*/p2=p1=head;while (strcmp(p0-name,p1-name)0&p1-next!=NULL)/*寻找待差位置*/p2=p1;p1=p1-next;/*指向后一个结点, p2 指向的结点在 p1 指向的结点之前 */if (strcmp(p0-name,p1-name)next=p1;if (head=p1) head=p0; /*插在链表首部*/else p2-next=p0; /*插在链表中间*/else /*插在链表尾结点之后*/p1-next=p0;p0-next=NULL;return(head); /*返回链

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 学术论文 > 毕业论文

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