数据结构课程设计实验报告—学生管理_第1页
数据结构课程设计实验报告—学生管理_第2页
数据结构课程设计实验报告—学生管理_第3页
数据结构课程设计实验报告—学生管理_第4页
数据结构课程设计实验报告—学生管理_第5页
已阅读5页,还剩16页未读 继续免费阅读

下载本文档

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

文档简介

1、精选优质文档-倾情为你奉上中南大学“数据结构”课程设计(学生管理系统)专业: 计算机类 班级: 姓名: 学号: 完成日期:二一年七月六日目录: 学生信息管理系统1.问题描述设计一个学生信息管理系统,实现对学生基本信息的添加、删除、修改和查询等操作。2.基本要求: 程序采用图形界面下进行交互的工作方式,完成如下功能:(1) 多种方式建立学生信息l 每个学生信息由学号、姓名、数学、英语和语文组成;l 可以通过手工录入每个学生信息,并在StudentFile.txt保存;l 也可以导入某个路径下存放学生信息的文本文件。(2) 浏览所有学生信息。(3) 按照学号对所有学生信息进行升序、降序排列,并输出

2、l 可选用冒泡、选择、快速排序等算法;l 不仅输出屏幕显示,还需要写入存放学生信息的文件。(4) 按姓名、学号等方式,实现对学生信息精确查询、模糊查询,并输出屏幕显示 l 精确查询结果演示查询“姓名是刘梅”同学信息,则输出 学号 姓名 数学 英语 语文 . 刘梅 88 90 78 .l 模糊查询结果演示查询“姓刘”的同学信息,则输出 学号 姓名 数学 英语 语文 . 刘梅 88 90 78 . 刘强 87 80 98 . 刘星 86 70 58 .l 能够实现连续多次查询 (5) 学生信息的插入、删除、修改。l 通过插入、删除和修改后,保持所有学生信息的有序性;l 插入、删除和修改后,对存放所

3、有学生信息的文件及时更新。(6) 数据的统计功能l 统计每个学生的平均分和总分;l 统计每个科目的平均分和最高分、最低分;l 将上述统计结果,写入存放学生信息的文件。3系统分析与设计流程图:打开系统结束case 1文件内有数据主菜单选择case 2case 3case 4case 5case 6case 7插入并排序修改删除查询输出统计输出退出导入系统学生信息由一个学生结构体保存其个人信息。学生结构体存放于一个结构体数组中,即线性表。各个学生按照学号排序,此处用到了直接插入排序。从数组的第一个元素开始存放学生结构体,0号做“哨兵”。信息的模糊查询:可通过学号或者姓名进行查询,用字符串的匹配完成

4、这一功能。信息的删除:精确查询到该学生信息的存储位置,然后逐个将后面的信息前移一个位置,实现删除功能。输出时的结果为顺序排列后的信息。启动系统,插入信息后,会在C盘根目录下生成一个STUDENTF的文件,学生信息保存在这里,进行删除或者插入后会实时更新文件内容。重新打开系统,程序会首先载入文件内容,即上次更新后的信息。我们也可以到C盘根目录下找到保存文件,查看其中内容。选择退出项后,退出系统。4 测试数据及结果 本程序以TC为编译运行环境。输入信息后,输出学生信息:修改号成绩为150.150.150后:文件内容:删除:删除这三个信息后输出:可以看到,原来有7组记录,删除3组记录后,剩余4组记录

5、,且有序。此时文件内容为:统计结果:主菜单: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; char name20; int english; int math; int chinese; int total;STU;typedef s

8、truct 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); rectangle(x1,y1,x2,y2); for(i=0;i<15;+i) delay(50000); setcolor(BLACK)

9、; 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(50000); int Index(char T1,char T2) unsigned int i; for(i=0;(i<strlen

10、(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_math,top_english,low_english,top_chinese,low_chinese; int choose; List

11、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 system, please input information"); goto gotostar; for(j=1;!feof(fp

12、_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' int choose; initgr(); /* BGI初始化 */ setbkcolor(BLACK); setcolor(BL

13、UE); 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); rectangle(80,310,240,360); floodfill(82,312,BLUE); rectangle(400,310,560,360

14、); 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,240,LIGHTRED); setcolor(YELLOW); settextjustify(1,1); settextstyle(1,0,1

15、); 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"); outtextxy(160,435,"5.output all"); outtextxy(480,435,&

16、quot;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(!kbhit() flash(395,205,565,265); break; case '3': while(!kbhit() f

17、lash(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 '7': while(!kbhit() flash_circle(320,240,28); break; default:break;

18、 if(kbkey%48<=7) choose = kbkey%48; kbkey = getch(); if('n' = kbkey|'r'=kbkey) break; /*getch();*/ /* 暂停一下,看看前面绘图代码的运行结果 */ closegraph(); /* 恢复TEXT屏幕模式 */ printf("choose=%dn",choose); fflush(stdin); switch(choose) case 1:while(1) i=L.length+1; printf("num:"); g

19、ets(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); printf("chinese:"); scanf("%d",&L.stui.chines

20、e);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","wb") = NULL) printf("Cannot open file strike any key exit!&q

21、uot;); 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 = getchar()='y') fflush(stdin);continue; else break; break; case 2:whil

22、e(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("numtnametMathtEnglishtChinesen"); printf("%st%st%dt%dt%dn",L.stui.nu

23、m,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("Math:"); scanf("%d",&L.stui.math); printf("En

24、glish:"); scanf("%d",&L.stui.english); printf("Chinese:"); scanf("%d",&L.stui.chinese); if(fp_stu = fopen("c:StudentFile.txt","wb") = NULL) printf("Cannot open file strike any key exit!"); getch(); exit(1); for(j=1;j<=L.leng

25、th;+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);continue; else break; break; case 3: while(1) printf("enter num t

26、o 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; if(fp_stu = fopen("c:StudentFile.txt","wb") = NULL)

27、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 = getchar()='y') ff

28、lush(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"); printf("numtnametMathtEnglishtChinesen"); printf(&quo

29、t;%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) printf("query is completedn"); printf("numtnametMathtE

30、nglishtChinesen"); 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;+i) if(0 = strcmp(L.stui.num,search_num) printf("查询完毕!n"); pri

31、ntf("学号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)"); if(yn = getchar()='y') fflush(stdin);continue; else break;/*

32、输入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("Press any key to the main menu!");getch(); break; case 6:for(i

33、=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_math; top_eng

温馨提示

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

评论

0/150

提交评论