




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、中南大学“数据结构课程设计学生管理系统专业: 计算机类 班级: 姓名: 学号: 完成日期:二一年七月六日目录:1 问题描述2 根本要求3系统分析与设计4 测试数据及结果 5 总结6 附录:源程序清单学生信息管理系统设计一个学生信息管理系统,实现对学生根本信息的添加、删除、修改和查询等操作。2.根本要求: 程序采用图形界面下进行交互的工作方式,完成如下功能:(1) 多种方式建立学生信息l 每个学生信息由学号、姓名、数学、英语和语文组成;l 可以通过手工录入每个学生信息,并在StudentFile.txt保存;l 也可以导入某个路径下存放学生信息的文本文件。(2) 浏览所有学生信息。(3) 按照学
2、号对所有学生信息进行升序、降序排列,并输出l 可选用冒泡、选择、快速排序等算法;l 不仅输出屏幕显示,还需要写入存放学生信息的文件。(4) 按姓名、学号等方式,实现对学生信息精确查询、模糊查询,并输出屏幕显示 l 精确查询结果演示查询“姓名是刘梅同学信息,那么输出 学号 姓名 数学 英语 语文 .2004112021 刘梅 88 90 78 .l 模糊查询结果演示查询“姓刘的同学信息,那么输出 学号 姓名 数学 英语 语文 .2004112021 刘梅 88 90 78 .2004112021 刘强 87 80 98 .2004112021 刘星 86 70 58 .l 能够实现连续屡次查询
3、(5) 学生信息的插入、删除、修改。l 通过插入、删除和修改后,保持所有学生信息的有序性;l 插入、删除和修改后,对存放所有学生信息的文件及时更新。(6) 数据的统计功能l 统计每个学生的平均分和总分;l 统计每个科目的平均分和最高分、最低分;l 将上述统计结果,写入存放学生信息的文件。3系统分析与设计流程图:翻开系统结束case 1文件内有数据主菜单项选择择case 2case 3case 4case 5case 6case 7插入并排序修改删除查询输出统计输出退出导入系统学生信息由一个学生结构体保存其个人信息。学生结构体存放于一个结构体数组中,即线性表。各个学生按照学号排序,此处用到了直接
4、插入排序。从数组的第一个元素开始存放学生结构体,0号做“哨兵。信息的模糊查询:可通过学号或者姓名进行查询,用字符串的匹配完成这一功能。信息的删除:精确查询到该学生信息的存储位置,然后逐个将后面的信息前移一个位置,实现删除功能。输出时的结果为顺序排列后的信息。启动系统,插入信息后,会在C盘根目录下生成一个STUDENTF的文件,学生信息保存在这里,进行删除或者插入后会实时更新文件内容。重新翻开系统,程序会首先载入文件内容,即上次更新后的信息。我们也可以到C盘根目录下找到保存文件,查看其中内容。选择退出项后,退出系统。4 测试数据及结果 本程序以TC为编译运行环境。输入信息后,输出学生信息:修改0
5、909083124号成绩为150.150.150后:文件内容:删除:删除这三个信息后输出:可以看到,原来有7组记录,删除3组记录后,剩余4组记录,且有序。此时文件内容为:统计结果:主菜单:5总结:本学期学习数据结构这门课程,在学习算法的同时,也在不断稳固着我们C语言的根底知识功底。本次实验使我深化理解了数据结构的有关知识。对于线性表,排序,查找,串的匹配等算法在实际中的应用有了更深一步的了解。真正认识到通用算法的作用,理解并应用这些算法,不但大大提高了编程的速度。同时这些算法的高效性,也使程序能够更有效的运行,时间复杂度更低。实验过程中应当注意一些细节性的问题,主要有,=与=经常写错。循环条件
6、的临界位置,是大于等于或者小于等于还是大于或小于,一不小心便会出错。 通过本次课程设计,我体会到了编程能力的中很重要的两点:良好的编程习惯。有一个良好的编程习惯是很重要的,例如一个好的命名习惯,可以让变量所表示的数据很明显,写程序时结构清楚,适当的添加注释。不但便于和其他人之间的交流,而且在日后重新看自己这段代码的时候,也易于看懂。否那么,一段时间后,自己写的代码也需要花费很多时间才能看懂。学习一些算法很重要。虽然随着科技开展,计算机速度越来越快,程序的运行速度的影响已经大大不如从前。但是,一个好的算法,能提高程序运行速度。而且,理解掌握好的算法,不但可以使人养成良好的编程思想,还能提高编程时
7、的速度。 另外的一点体会是,不但要提高自己的编程能力,而且还要注意培养自己的表达能力。能够将一个程序的功能以一种简单明了的方式表达出来很重要。现在对着老师讲,尚且讲不好,将来,面对客户呢?这是通过本次实验,我意识到的又一个很重要的问题。6附录源代码:#include <stdio.h>#include <stdlib.h>#include <conio.h>#include <string.h>#include "graphics.h"typedef struct Student long key; char num11; c
8、har name20; int english; int math; int chinese; int total;STU;typedef struct STU *stu; int length;List;void initgr(void) /* BGI初始化 */ int gd = DETECT, gm = 0; /* 和gd = VGA,gm = VGAHI是同样效果 */ initgraph(&gd, &gm, "");void flash(int x1,int y1,int x2,int y2) int i; setcolor(YELLOW); re
9、ctangle(x1,y1,x2,y2); for(i=0;i<15;+i) delay(50000); setcolor(BLACK); rectangle(x1,y1,x2,y2); for(i=0;i<10;+i) delay(50000); void flash_circle(int x,int y,int r) int i; setcolor(YELLOW); circle(x,y,r); for(i=0;i<15;+i) delay(50000); setcolor(BLACK); circle(x,y,r); for(i=0;i<15;+i) delay(
10、50000); int Index(char T1,char T2) unsigned int i; for(i=0;(i<strlen(T1)&&(i<strlen(T2);+i) if(T1i!=T2i) break; if(strlen(T2) = i) return 1;/*1说明匹配成功*/ else return 0;int main(void) float aver_math,aver_english,aver_chinese; long all_math=0,all_english=0,all_chinese=0; int top_math,low_
11、math,top_english,low_english,top_chinese,low_chinese; int choose; List L; int i; int j;FILE *fp_stu; char search_num11; char yn; L.stu = (STU *)malloc(100*sizeof(STU); L.length = 0; if(1) if(fp_stu = fopen("c:StudentFile.txt","rb") = NULL) printf("the first time to use the s
12、ystem, please input information"); goto gotostar; for(j=1;!feof(fp_stu);+j) fscanf(fp_stu,"%s%s%d%d%d",&L.stuj.num,&L.,&L.stuj.math,&L.stuj.english,&L.stuj.chinese); +L.length; -L.length;gotostar:printf("%dn",L.length); while(1) char kbkey='1
13、' int choose; initgr(); /* BGI初始化 */ setbkcolor(BLACK); setcolor(BLUE); setfillstyle(SOLID_FILL,BLUE);/*这句话的作用,可以不为BLUE*/ rectangle(120,80,500,160); floodfill(162,82,BLUE); /*必须和边框颜色相同*/ rectangle(80,210,240,260); floodfill(82,212,BLUE); rectangle(400,210,560,260); floodfill(402,212,BLUE); recta
14、ngle(80,310,240,360); floodfill(82,312,BLUE); rectangle(400,310,560,360); floodfill(402,312,BLUE); rectangle(80,410,240,460); floodfill(82,412,BLUE); rectangle(400,410,560,460); floodfill(401,413,BLUE); setcolor(LIGHTRED); setfillstyle(SOLID_FILL,LIGHTRED); circle(320,240,25); /*画圆*/ floodfill(320,2
15、40,LIGHTRED); setcolor(YELLOW); settextjustify(1,1); settextstyle(1,0,1); outtextxy(320,120,"Student Information Management System"); outtextxy(160,235,"1.Insert"); outtextxy(480,235,"2.alter"); outtextxy(160,335,"3.detele"); outtextxy(480,335,"4.search&q
16、uot;); outtextxy(160,435,"5.output all"); outtextxy(480,435,"6.statistics"); outtextxy(320,240,"7.exit"); outtextxy(320,50,"Author:Zhao Yingnan"); while(1) switch(kbkey) case '1': while(!kbhit() flash(75,205,245,265); break; case '2': while(!kb
17、hit() flash(395,205,565,265); break; case '3': while(!kbhit() flash(75,305,245,365); break; case '4': while(!kbhit() flash(395,305,565,365); break; case '5': while(!kbhit() flash(75,405,245,465); break; case '6': while(!kbhit() flash(395,405,565,465); break; case '
18、;7': while(!kbhit() flash_circle(320,240,28); break; default:break; if(kbkey%48<=7) choose = kbkey%48; kbkey = getch(); if('n' = kbkey|'r'=kbkey) break; /*getch();*/ /* 暂停一下,看看前面绘图代码的运行结果 */ closegraph(); /* 恢复TEXT屏幕模式 */ printf("choose=%dn",choose); fflush(stdin); s
19、witch(choose) case 1:while(1) i=L.length+1; printf("num:"); gets(L.stui.num); printf("name:"); gets(L.); printf("math:"); scanf("%d",&L.stui.math);fflush(stdin); printf("english:"); scanf("%d",&L.stui.english);fflush(stdin)
20、; printf("chinese:"); scanf("%d",&L.stui.chinese);fflush(stdin); L.stu0 = L.stui; for(;i>=0;-i) L.stui.key = atol(L.stui.num); for(j=L.length;L.stu0.key<L.stuj.key;-j) L.stuj+1 = L.stuj; L.stuj+1 = L.stu0; +L.length; if(fp_stu = fopen("c:StudentFile.txt","
21、;wb") = NULL) printf("Cannot open file strike any key exit!"); getch(); exit(1); for(j=1;j<=L.length;+j) fprintf(fp_stu,"%st%st%dt%dt%drn",L.stuj.num,L.,L.stuj.math,L.stuj.english,L.stuj.chinese); fclose(fp_stu); printf("continue?(y/n)"); if(yn = getcha
22、r()='y') fflush(stdin);continue; else break; break; case 2:while(1) printf("input the num to alter:"); gets(search_num); for(i=1;i<=L.length;+i) if(0 = strcmp(L.stui.num,search_num) printf("query is completed!the student's information:n"); printf("numtnametMat
23、htEnglishtChinesen"); printf("%st%st%dt%dt%dn",L.stui.num,L.,L.stui.math,L.stui.english,L.stui.chinese); break; printf("i=%d,length=%dn",i,L.length); if(i>L.length) printf("not find!nre");continue; printf("input info to change:n"); printf(&quo
24、t;Math:"); scanf("%d",&L.stui.math); printf("English:"); scanf("%d",&L.stui.english); printf("Chinese:"); scanf("%d",&L.stui.chinese); if(fp_stu = fopen("c:StudentFile.txt","wb") = NULL) printf("Cannot open f
25、ile strike any key exit!"); getch(); exit(1); for(j=1;j<=L.length;+j) fprintf(fp_stu,"%st%st%dt%dt%drn",L.stuj.num,L.,L.stuj.math,L.stuj.english,L.stuj.chinese); fclose(fp_stu); fflush(stdin); printf("continue?(y/n)"); if(yn = getchar()='y') fflush(stdin)
26、;continue; else break; break; case 3: while(1) printf("enter num to delete:"); gets(search_num); for(i=1;i<=L.length;+i) if(0 = strcmp(L.stui.num,search_num) break; if(i>L.length) printf("no num to delete!n"); else for(j = i;j<L.length;+j) L.stuj = L.stuj+1; -L.length; i
27、f(fp_stu = fopen("c:StudentFile.txt","wb") = NULL) printf("Cannot open file strike any key exit!"); getch(); exit(1); for(j=1;j<=L.length;+j) fprintf(fp_stu,"%st%st%dt%dt%drn",L.stuj.num,L.,L.stuj.math,L.stuj.english,L.stuj.chinese); fclose(fp_stu)
28、; printf("continue?(y/n)"); if(yn = getchar()='y') fflush(stdin);continue; else break; break; case 4:while(1) printf("enter the searching num or name:"); gets(search_num);j=0; for(i=1;i<=L.length;+i) if(1 = Index(L.stui.num,search_num) printf("query is completedn&
29、quot;); printf("numtnametMathtEnglishtChinesen"); printf("%st%st%dt%dt%dn",L.stui.num,L.,L.stui.math,L.stui.english,L.stui.chinese); +j; if(i = L.length) break; continue; if(j>0&&j=L.length) break; for(i=1;i<=L.length;+i) if(1 = Index(L.,search_num
30、) printf("query is completedn"); printf("numtnametMathtEnglishtChinesen"); printf("%stt%st%dt%dt%dn",L.stui.num,L.,L.stui.math,L.stui.english,L.stui.chinese); +j; if(i = L.length) break; continue; if(j>0&&j=L.length) break; /*for(i=1;i<=L.length;+
31、i) if(0 = strcmp(L.stui.num,search_num) printf("查询完毕!n"); printf("学号t姓名t数学t英语t语文n"); printf("%st%st%dt%dt%dn",L.stui.num,L.,L.stui.math,L.stui.english,L.stui.chinese); break; */ if(i>L.length) printf("not find!n"); printf("continue?(y/n)"
32、); if(yn = getchar()='y') fflush(stdin);continue; else break;/*输入y继续,输入除y以外的字符跳出循环*/ break; case 5:for(i=1;i <= L.length;+i) printf("numttnametMathtEnglishtChinesen"); printf("%st%st%dt%dt%dn",L.stui.num,L.,L.stui.math,L.stui.english,L.stui.chinese); printf(&q
33、uot;Press any key to the main menu!");getch(); break; case 6:for(i=1;i<=L.length;+i) L.stui.total = L.stui.math+L.stui.english+L.stui.chinese; for(i=1;i<=L.length;+i) all_math = all_math + L.stui.math; all_english = all_english + L.stui.english; all_chinese = all_english + L.stui.chinese; printf("l.stu%d.math=%dn",i,all_math); aver_math = (float)all_math/L.length; aver_english = (float)all_english/L.length; aver_chinese = (float)all_chinese/L.length; for(i=1;i<=L.length;i+) top_math = L.stu1.math; top_math = (top_math<L.stui.math)?L.stui.math:top
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 青年发展面试题及答案
- 未来的商务英语职业市场的标准及技能测评题型试题及答案
- 医学护理教学课件
- 注册土木工程师考试复习资料的筛选与使用技巧分享试题及答案
- 火灾化学的原因及预防试题及答案
- 解析2025年大学化学试题及答案
- 住宅消防维修采购合同范例
- 佛山用工合同范例
- 上海买房赠予合同范例
- 办理环保证合同标准文本
- 《思想道德与法治》课件-第三章 继承优良传统 弘扬中国精神
- NB/T 11646-2024井工煤矿采空区自然发火监测预警技术规范
- 2025年劳动与社会保障专业考核试卷及答案
- 《危险化学品企业安全生产标准化规范》专业深度解读与应用培训指导材料之1:1范围+3术语和定义(雷泽佳编制-2025A0)
- 上海上海闵行职业技术学院招聘60人笔试历年参考题库附带答案详解
- 《戏曲服饰图案解析》课件
- 2025届高三英语一轮复习“语法填空”题型说题课件
- 第18课《井冈翠竹》课件-2024-2025学年统编版语文七年级下册
- 第16课《有为有不为》公开课一等奖创新教学设计
- 【MOOC】《思想道德与法治》(东南大学)章节中国大学慕课答案
- MOOC 中医与辨证-暨南大学 中国大学慕课答案
评论
0/150
提交评论