数据结构课程设计-公司职工管理系统.doc_第1页
数据结构课程设计-公司职工管理系统.doc_第2页
数据结构课程设计-公司职工管理系统.doc_第3页
数据结构课程设计-公司职工管理系统.doc_第4页
数据结构课程设计-公司职工管理系统.doc_第5页
已阅读5页,还剩17页未读 继续免费阅读

下载本文档

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

文档简介

辽宁工业大学 课课 程程 设设 计计 说说 明明 书书 题目:题目: 数据结构课程设计数据结构课程设计 学院(系):学院(系): 电子与信息工程学院电子与信息工程学院 专业班级:专业班级: 计算机科学与技术专业计算机科学与技术专业 学学 号:号: 学生姓名:学生姓名: 指导教师:指导教师: 教师职称:教师职称: 副教授副教授 起止时间:起止时间: 2009.12.012009.12.012009.12.082009.12.08 课程设计(论文)任务及评语课程设计(论文)任务及评语 院(系):电子与信息工程 教研室: 软件工程 学 号080401019学生姓名朱江雨专业班级计算机 081 课程设计 (论文) 题目 数据结构课程设计 课程设计(论文)任务 1可从前四类题目中,每类选择一个题目,共需完成四个题目,或从每五类题目中选择一题, 要求每个题目用标准的 C 语言程序实现,另外,完成思考题一题,思考题须写出相应的类 C 算法即可。 2每个题目编写源程序时,每个子功能定义为相应的子函数,在主函数中调用各子函数, 程序结构清晰。 3 除了指定的之外,数据的存储结构根据需要自行定义。 4 输入的数据由键盘输入。 5 分析算法的时间复杂度,要求算法的效率尽可能高。 6 验证排序算法的稳定性。 指导教师评语及成绩 成绩: 指导教师签字: 年 月 日 目 录 第第 1 章章课程设计目的与要求课程设计目的与要求.1 1.1 课程设计目的.1 1.2 课程设计的实验环境.1 1.3 课程设计的预备知识.1 1.4 课程设计要求.1 第第 2 章章 课程设计内容课程设计内容.2 2.1 第五类题目.2 2.2 题目的具体实现.2 2.3 题目内容.2 2.4 思考题解析.16 总总 结结.18 参考文献参考文献.19 1 第 1 章 课程设计目的与要求 1.1 课程设计目的 本课程设计是计算机科学与技术专业、软件工程专业的专业技术实践课。 本实践课的主要目的是:使学生学会利用在课堂中学过的理论知识,解决相应的实 际问题,深入理解和灵活掌握所学的内容,培养学生理论和实践相结合的能力,培养学 生分析问题解决问题的能力。同时,在实验步骤规范化、程序设计方法等方面受到比较 系统和规范的训练。通过实践设计使学生进一步加深对程序设计的规范化及对复杂程序 设计步骤的理解。 1.2 课程设计的实验环境 PC 机,WindowsXP,Win-tc。 1.3 课程设计的预备知识 C 语言程序设计、高级程序设计应用、数据结构。 1.4 课程设计要求 (1)认真查找资料,分析每个题目应选择的数据结构(逻辑结构和物理结构) ; (2)按时到实验室调试程序,遵守实验室的规章制度,爱护设备; (3)每个题目编写源程序时,每个子功能定义为相应的子函数,在主函数中调用 各子函数,程序结构清晰,有必要的注释,可读性强。 (4)程序健壮性强,当数据输入错误时,要进行相应的处理; (5)分析算法的时间复杂度,要求算法的效率尽可能高; (6)对于排序算法,要验证排序算法的稳定性。 2 第 2 章 课程设计内容 2.1 第五类题目 1、简单的职工管理系统 a.问题描述 对单位的职工进行管理,包括插入、删除、查找、排序等功能。 b.要求 职工对象包括姓名、性别、出生年月、工作年月、学历、职务、住址、电话等信息。 (1)新增一名职工:将新增职工对象按姓名以字典方式职工管理文件中。 (2)删除一名职工:从职工管理文件中删除一名职工对象。 (3)查询:从职工管理文件中查询符合某些条件的职工。 (4)修改:检索某个职工对象,对其某些属性进行修改。 (5)排序:按某种需要对职工对象文件进行排序。 c.实现提示 职工对象数不必很多,便于一次读入内存,所有操作不经过内外存交换。 (1)由键盘输入职工对象,以文件方式保存。程序执行时先将文件读入内存。 (2)对职工对象中的姓名按字典顺序进行排序。 (3)对排序后的职工对象进行增、删、查询、修改、排序等操作。 2.2 题目的具体实现 (一)题目应实现的具体功能 (1)新增一名职工:将新增职工对象按姓名以字典方式职工管理文件中。 (2)删除一名职工:从职工管理文件中删除一名职工对象。 (3)查询:从职工管理文件中查询符合某些条件的职工。 (4)修改:检索某个职工对象,对其某些属性进行修改。 (5)排序:按某种需要对职工对象文件进行排序。 2.3 题目内容 (一)题目:简单的职工管理系统 3 (二)题目:运用结构 (1)数据结构:顺序表 (2)存储结构:数组 (三)完整的源程序 #include #define maxsize 100 typedef struct worker char name15; char sex6; char birthday15; char workage15; char xueli15; char position15; char adress15; char tel12; worker; typedef struct worker wmaxsize+1; int length; *work,wor; int n=0; char password10=080401019; void creatwork(work p,int t) int i,m; p-length=0; for(i=1;); getchar(); do printf(ninput %ss sex,1:man,2:woman ,); scanf(%d, getchar(); switch(m) case 1:strcpy(p-wi.sex,man);break; case 2:strcpy(p-wi.sex,woman);break; default:printf(input wrong,please input anain);m=0;break; while(m=0); 4 printf(ninput %ss birthday ,p-wi.sex); scanf(%s,p-wi.birthday); printf(ninput the time when the worker begin to work ); scanf(%s,p-wi.workage); printf(ninput which school the worker graduate frow ); scanf(%s,p-wi.xueli); printf(ninput position ); scanf(%s,p-wi.position); printf(ninput adress ); scanf(%s,p-wi.adress); printf(ninput tel ); scanf(%s,p-wi.tel); p-length+; save(p); int save(work p) FILE *fp; char filename20; int i; printf(Please input the filenamen); scanf(%s,filename); if(fp=fopen(filename,wb)=NULL) printf(cant open filen); return; fwrite( for(i=1;iwi),sizeof(worker),1,fp)!=1) printf(file write errorn); fclose(fp); void load(work p) FILE *fp; int i; char filename20; p-length=0; printf(Please input the filenamen); scanf(%s,filename); if(fp=fopen(filename,rb)=NULL) printf(cannot open filen); return; 5 printf(File has been open:n); printf(File is:n); fread( printf(%dn,n); getch(); for (i=1;iwi,sizeof(struct worker),1,fp); p-length+; fclose(fp); void shellsort(work q,int data,int t) int k; for(k=0;,)w0=p-wi; for(j=i-dk;j0 p-wj+dk=p-w0; void insertwork(work p,worker q) int i,j; i=p-length; while(strcmp(,)wi+1=p-wi; i-; p-wi+1=q; p-length+; 6 n+; int delete(work p,char *name) int i=1,j,k; if(p-length=0) return 0; while(strcmp(name,)!=0) if(strcmp(name,()=0) k=i; for(j=k;jlength;j+) p-wj=p-wj+1; p-length-; n-; return k; else return 0; int changework(work p,char *name) int i=1,j,m; system(cls); while(strcmp(name,)!=0) if(strcmp(name,()=0) printf(n do you want to change the works name,1:yes,2:no); scanf(%d, if(j=1) printf(n please input name ); scanf(%s,); printf(n do you want to change the works sex,1:yes,2:no); scanf(%d, if(j=1) getchar(); do printf(ninput %ss sex,1:man,2:woman ,); scanf(%d, getchar(); switch(m) 7 case 1:strcpy(p-wi.sex,man);break; case 2:strcpy(p-wi.sex,woman);break; default:printf(input wrong,please input anain);m=0;break; while(m=0); printf(n do you want to change the works birthday,1:yes,2:no); scanf(%d, if(j=1) printf(n please input birthday ); scanf(%s,p-wi.birthday); printf(n do you want to change the works workage,1:yes,2:no); scanf(%d, if(j=1) printf(n please input workage ); scanf(%s,p-wi.workage); printf(n do you want to change the works xueli,1:yes,2:no); scanf(%d, if(j=1) printf(n please input xueli ); scanf(%s,p-wi.xueli); printf(n do you want to change the works position,1:yes,2:no); scanf(%d, if(j=1) printf(n please input position ); scanf(%s,p-wi.position); printf(n do you want to change the works adress,1:yes,2:no); scanf(%d, if(j=1) printf(n please input adress ); scanf(%s,p-wi.adress); printf(n do you want to change the works tel,1:yes,2:no); scanf(%d, if(j=1) 8 printf(n please input tel ); scanf(%s,p-wi.tel); return i; else return 0; int chayuework(work p,char *name) int i=1; system(cls); while(strcmp(name,()!=0 if(strcmp(name,()=0) printf(nthe %ds worker name is %s,i,); printf(nthe %ds worker sex,is %s,i,p-wi.sex); printf(nthe %ds worker birthday is %s,i,p-wi.birthday); printf(nthe %ds worker workage is %s,i,p-wi.workage); printf(nthe %ds worker graduate from %s,i,p-wi.xueli); printf(nthe %ds worker position is %s,i,p-wi.position); printf(nthe %ds worker adress is %s,i,p-wi.adress); printf(nthe %ds worker tel is %s,i,p-wi.tel); return i; else return 0; void qsort(work l,int low,int high) int p=0; if(loww0=l-wlow; while()=0) high-; l-wlow=l-whigh; while(,)whigh=l-wlow; l-wlow=l-w0; p=high; return p; int travser(work p) int i; for(i=1;ilength;i+) system(cls); printf(nthe %ds worker name is %s,i,); printf(nthe %ds worker sex,is %s,i,p-wi.sex); printf(nthe %ds worker birthday is %s,i,p-wi.birthday); printf(nthe %ds worker workage is %s,i,p-wi.workage); printf(nthe %ds worker graduate from %s,i,p-wi.xueli); printf(nthe %ds worker position is %s,i,p-wi.position); printf(nthe %ds worker adress is %s,i,p-wi.adress); printf(nthe %ds worker tel is %s,i,p-wi.tel); system(pause); printf(nthere are %d workers,p-length); void main() char s10,name15; int flag=0,a,b,c,d,e,f,i,g,j,k,data3,m=3; worker p; wor v,w; work worke,workee; worke= workee= do printf(please input you mima:n); scanf(%s,s); if(!strcmp(s,password) printf(congrulationn); flag=1; 10 break; else printf(input wrong,please input anainn:n); m-; while(m0); if(!flag) printf(you have inputtden threes times.n); return; do getchar(); printf(do you need to recreatn1:yesn2:non); scanf(%d, switch(g) case 1:printf(input how many workers do you needn); scanf(%d, creatwork(workee,n); break; case 2:break; default:printf(input wrong,please inout againn); g=0; break; while(g=0); printf(please choose which function do you need:n0:loadf,n1:shellsort,n2:insertwork,n3:delete,n4:chaxun,n5:changework,n6:qsort,n7:t ravser,n8:save,n9:game over,nyou choose is); scanf(%d, while(k!=9) switch(k) case 0:load(worke);break; case 1:for(i=0;i3;i+) printf(input %dth numbern,i); scanf(%d, shellsort(worke,data,3); 11 break; case 2:printf(ninput name ); scanf(%s,); getchar(); e=chayuework(worke,); if(e!=0) printf(n there has a elemtype that has the same name,do you need to insert againn1:yesn2:no); scanf(%d, if(f=2) break; do printf(ninput %ss sex,1:man,2:woman ,); scanf(%d, getchar(); switch(d) case 1:strcpy(p.sex,man); break; case 2:strcpy(p.sex,woman); break; default:printf(input wrong,please input anain);d=0;break; while(d=0); printf(ninput %ss birthday ,p.sex); scanf(%s,p.birthday); printf(ninput the time when the worker begin to work ); scanf(%s,p.workage); printf(ninput which school the worker graduate from ); scanf(%s,p.xueli); printf(ninput position ); scanf(%s,p.position); printf(ninput adress ); scanf(%s,p.adress); printf(ninput tel ); scanf(%s,p.tel); insertwork(worke,p); break; case 3:printf(input the workers name you want to delete); scanf(%s,name); a=delete(worke,name); if(a=0) printf(nthere is not the worker you want delete); 12 else printf(nthe worker you want to delete is the %ds worker,a); break; case 4:printf(input the workers name you want to chaxun); scanf(%s,name); b=chayuework(worke,name); if(b=0) printf(nthere is not the worker you want delete); else printf(nthe worker you want to chaxune is the %ds worker,b); break; case 5:printf(input the workers name you want to change); scanf(%s,name); c=changework(worke,name); if(c=0) printf(nthere is not the worker you want change); else printf(nthe worker you want to change is the %ds worker,c); break; case 6:qsort(worke,1,n); break; case 7:travser(worke); break; case 8:save(worke); default:printf(Error!Please choose again!);break; system(cls); printf(please choose which function do you need:n0:loadf,n1:shellsort,n2:insertwork,n3:delete,n4:chaxun,n5:changework,n6:qsort,n7:t ravser,n8:save,n9:game over,nyou choose is); scanf(%d, getch(); (4)程序的输入和输出(可附图) 图 2-1 向 w数组中输入数据并输出可以选择 13 图 2-2 选择向 w数组中输入数据并输出,显示菜单界面 图 2-3 选择不向 w数组中输入数据 图 2-4 输入自己的添加选择并显示添加结果 图 2-5 功能菜单 14 图 2-6 输入文件名并打开文件将其值赋给 v 图 2-7 将 v中职工信息输出 图 2-8 运用希尔排序使元素信息有序 图 2-9 顺序插入一个元素 15 图 2-10 删除一个职工信息 图 2-11 查阅某个职工信息 图 2-12 修改某个职工的某些信息 图 2-13 快速排序使职工信息按字典顺序存储 16 图 2-14 使元素顺序输出 按 8 整个程序运行完毕 (5)调试程序中遇到的问题及解决方案 问题 1:在输出时由于信息太多致使有的信息不能在输出栏中显示。 问题 2:输出的无用信息不能及时的清除掉。 解决方案:经过查资料知道运用 system(“pauses”);可以显示最近文件内容,解决了第一个问题。后 有知道运用 system(“sls”);可以删除最近输出的内容,解决了第二个问题。 2.4 思考题解析 所选择的思考题:试设计构造一个哈希表的算法。哈希函数用除留余数法构造,用线 性探测再散列或链地址法处理冲突。程序如下: #include typedef struct student int key; char name15; int chengji; int panduan; student,*stude; void creat(stude st,int n) int i,b,key; stude s; s=st; for(i=0;in;i+) si.panduan=0; for(i=0;in;i+) printf(please input the key of the %dth elemtypen,i); scanf(%d, b=bijiao(s,key,n); sb.key=key; printf(please input the name of the %dth elemtypen,i); scanf(%s,); 17 printf(please input the chengji of the %dth elemtypen,i); scanf(%d, sb.panduan=1; int bijiao(stude stu,int key,int n) int a,i=0; do a=(key+i)%n; i+; while(stua.panduan=1); return a; void print(stude stu,int n) int i; for(i=0;in;i+) if(stui.panduan=1) printf(the key of the %dth elemtype is %dn,i,stui.key); printf(the name of the %dth elemtype is %sn,i,); printf(the chengji of the %dth elemtype is %dn,i,stui.chengji); void main() int a,b,c,i; student stu11; stude st; st=stu; printf(please input the number of the elemtypes do you need:i=11n); scanf(%d, creat(

温馨提示

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

评论

0/150

提交评论