数据结构课程设计报告 叶延风

上传人:第*** 文档编号:78872625 上传时间:2019-02-15 格式:PDF 页数:25 大小:147.83KB
返回 下载 相关 举报
数据结构课程设计报告  叶延风_第1页
第1页 / 共25页
数据结构课程设计报告  叶延风_第2页
第2页 / 共25页
数据结构课程设计报告  叶延风_第3页
第3页 / 共25页
数据结构课程设计报告  叶延风_第4页
第4页 / 共25页
数据结构课程设计报告  叶延风_第5页
第5页 / 共25页
点击查看更多>>
资源描述

《数据结构课程设计报告 叶延风》由会员分享,可在线阅读,更多相关《数据结构课程设计报告 叶延风(25页珍藏版)》请在金锄头文库上搜索。

1、数据结构课程设计 1 数据结构课程设计 报告 专业 信息与计算科学 学号: 姓名: 数据结构课程设计 2 目录 一 需求分析 二 程序主要功能 三 有特色的函数 四 出现的问题及解决方案 五 程序源代码 六 课程设计心得体会 七 附录 数据结构课程设计 3 一需求分析 一 题目:学生成绩管理系统 设每个学生有如下的信息: 学号姓名年龄性别课 程 1 成绩教师课 程 2 成绩教师 基本信息所学的课程 1 信息所学课程 2 信息 二数据结构 采用 Hash 表加上课程链表的结构。 其中 hash 表中存放每个学生的基本信息, 并由课程指针指向该同学所学的课程链表。 Hash 表 课 程 1 成 绩

2、 教 师 下 一 门 课 指 针 Hash 表长度=11 二程序主要功能 程序功能: a) 建立 hash 表和成绩链表 i.输入 10 位同学信息 ii.hash 函数 。H=(学号的后三位)MOD 11 。用线性探测再散列法解决冲突 b) 查询 学号姓名年龄性别课 程 指 针 8880 5 stud s 19M Pascal80Teacher1 Data stru 90Teacher4 数据结构课程设计 4 i.显示全部信息 ii.按学号查找,使用 hash 函数 iii.按姓名查找,顺序查找 iv.按男/女生查找 v.某年级的全部课程 vi.听某教师讲授课的全部学生 vii.选修某门课程

3、的全部学生 要求:找到,显示出有关信息;找不到,给出有关的提示信息。 c) 排序 i.按学号从小到大排序。 ii.按年龄从大到小排序。 iii.按个人总成绩从大到小排序。 要求:排序后不能破坏原先的数据。 d) 统计 i.男/女生人数。 ii.每个人的平均成绩。 iii.各年级的平均年龄。 iv.各门课的平均成绩。 上机要求 e) 输出信息须清晰美观; 交程序清单及上机报告 三有特色的函数 1.Status SearchHash(HashTable H,int K,int while(H.pointp.key!=NULLKEY collision(p,+c); if (K=H.pointp.k

4、ey) return SUCCESS; else return UNSUCCESS; 2.Status SeInsertHash(HashTable c=0; if(SearchHash(H,e.key,p,c) return BAD; else H.pointp=e; +H.count; H.pointp.student.Coursees=(CourseList)malloc(sizeof(Course); H.pointp.student.Coursees-next=NULL; CreateList(H.pointp.student.Coursees,dataFile,2); return

5、 OK; 3void TraverseHash(HashTable H)/遍历哈希表 for(int i=0;i #include 数据结构课程设计 6 #include #include #include #include #include #include #define MAXSIZE 20 #define N 10 #define HMAX 97 #define TRUE 1 #define FALSE 0 #define OK 1 #define ERROR 0 #define SUCCESS 1 #define SUCCESS 1 #define UNSUCCESS 0 #defi

6、ne BAD -1 #define NULLKEY 0 typedef int Status; typedef struct Course char name20; int score; char teacher20; Course *next; Course,*CourseList; typedef struct char number10; char name10; int age; char sex3; struct Course *Coursees; Student; struct Hash int key; Student student; ; typedef struct Hash

7、 *point; int count; int sizeindex; HashTable; 数据结构课程设计 7 typedef struct Hash rMAXSIZE+1; int length; SqList; Status InitHashTable(HashTable H.count=0; H.sizeindex=0; H.point=(Hash*)malloc(11*sizeof(Hash); if(!H.point) coutp-name; dataFilep-score; dataFilep-teacher; s-next=p; p-next=NULL; s=p; Status

8、 InsertHash(HashTable c=0; if(SearchHash(H,e.key,p,c) return BAD; else H.pointp=e; +H.count; return OK; Status SeInsertHash(HashTable c=0; if(SearchHash(H,e.key,p,c) return BAD; else H.pointp=e; +H.count; H.pointp.student.Coursees=(CourseList)malloc(sizeof(Course); H.pointp.student.Coursees-next=NUL

9、L; CreateList(H.pointp.student.Coursees,dataFile,2); return OK; 数据结构课程设计 9 voidListTraverse(CourseListL) Course *p=L-next; while(p) coutnamescoreteacher; p=p-next; void TraverseHash(HashTable H)/遍历哈希表 for(int i=0;i=pivotkey) -high; L.rlow=L.rhigh; while(lowH.rj+1.key) +j; if(!(rc.keyH.rj.key) break;

10、 H.rs=H.rj; s=j; H.rs=rc; void HeapSort(SqList for(int i=H.length/2;i0;-i) HeapAdjust(H,i,H.length); for(i=H.length;i1;-i) rr=H.r1; H.r1=H.ri; H.ri=rr; HeapAdjust(H,1,i-1); void ShowHSort(SqList people1,HashTable people)/显示 int i,j=0; people1.length=people.count; for(i=0;i=SRj.key) TRk=SRi+; else TR

11、k=SRj+; if (inext-score +people.pointi.student.Coursees-next-next-score; people1.r+j=people.pointi; MergeSort(people1); for(i=1;ie.student.number;dataFilee.student.name; dataFilee.student.age;dataFilee.student.sex; e.key=atol(e.student.number)%1000; SeInsertHash(people,e,dataFile); 数据结构课程设计 14 dataF

12、ile.close(); void HeadShow1(void) couta; K=atol(a)%1000;/求学号后三位 p=Hash1(K); while(H.pointp.key!=NULLKEY collision(p,+c); if (K=H.pointp.key for(i=0;i=0) coutc; while(strcmp(c,“男“)!=0) HeadShow1(); for(i=0;id; for(i=0;if; for(i=0;inext-teacher)=0|strcm p(f,H.pointi.student.Coursees-next-next-teacher)

13、=0) 数据结构课程设计 17 S=1; coutg; for(i=0;inext-name)=0|strcmp(g, H.pointi.student.Coursees-next-next-name)=0) S=1; coutc; while(strcmp(c,“男“)!=0) if(strcmp(c,“男“)=0) for(i=0;inext-score+H.pointi.student.Cours ees-next-next-score; ave=(num+1)/2; coutd; for(i=0;ig; for(i=0;inext-name)=0) S=1; +count; num+=

14、double(H.pointi.student.Coursees-next-score); if(strcmp(g,H.pointi.student.Coursees-next-next-name)=0) S=1; +count; num+=double(H.pointi.student.Coursees-next-next-score); if(S=1) ave=num/count; couta; switch(a) case 1: system(“cls“); show1(); 数据结构课程设计 22 t=1; while(t) cinb; switch(b) case 1: HeadShow1(); TraverseHash(people); system(“pause“); system(“cls“); show1(); break; case 2: NumSearch(people); system(“pause“); system(“cls“); show1(); break; case 3: Name

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

当前位置:首页 > 高等教育 > 大学课件

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