




免费预览已结束,剩余12页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
一、课程设计的内容将所选的题目的内容copy过来,包括功能要求等等。不记得可以看附录。字体是楷体,注意排版,不要让下一页(老师签名那页)跨页!职工工作量统计系统编写有一个程序,该程序输入职工工号和完成的产品数量,程序允许同一职工有多次输入,由程序对其完成的产品数量实现累计。程序按完成数量对他们排序,并确定他们的名次。按完成的产品数量由多到少的顺序,输出名次、同一名次的职工人数及他们的工号(工号由小到大顺序输出)。要求程序用有序链表存储数据信息。二、课程设计的要求与数据1、进一步掌握和利用C语言进行程设计的能力;2、进一步理解和运用结构化程序设计的思想和方法;3、初步掌握开发一个小型实用系统的基本方法;4、学会调试一个较长程序的基本方法;5、学会利用流程图或N-S图表示算法;6、掌握书写程序设计开发文档的能力。三、课程设计应完成的工作1、编写完成相应题目的程序;2、编写课程设计报告,课程设计报告的内容应包括以下6个部分:1) 需求分析:包括设计题目、设计要求以及系统功能需求分析;2) 总体设计:包括系统总体设计框架和系统功能模块图;3) 详细设计:包括主要功能模块的算法设计思路以及对应的工作流程图;4) 调试分析过程描述:包括测试数据、测试输出结果,以及对程序调试过程中存在问题的思考(列出主要问题的出错现象、出错原因、解决方法及效果等,适当的包含结果截图);5) 总结:课程设计完成了哪些功能,有没有什么扩展功能?还有哪些地方需要改进?课程设计过程中的学习体会与收获、对本次课程设计的认识以及自己的建议等内容; 6) 附录:主要源程序代码,含必要的注释。3、答辩:在实验室建立程序运行的环境,并在指导教师的监督下,独立解 决问题、运行程序和回答教师提出的问题。四、课程设计进程安排序号设计各阶段内容地点起止日期1下达任务书,说明设计要求;收集资料实验3#5176.182总体方案设计、详细设计实验3#5176.193编写程序,调试分析实验3#5176.204撰写报告并上交,答辩实验3#5176.21五、应收集的资料及主要参考文献注意参考文献的格式要求,依照下面的两个的格式填写,可以是网页,书,杂志, 合计最少3本(已有的两个谭老师的算2本).1 谭浩强.C程序设计(第三版)M,北京:清华大学出版社,2005.92 谭浩强. C程序设计题解与上机指导(第三版)M,北京:清华大学出版社,2005.73 宋箭. C语言程序设计,上海,上海科学普及出版社,2005.64 周启海.C语言程序设计教程,北京,机械工业出版社,2004.1发出任务书日期: 2007年 6 月 18 日 指导教师签名:计划完成日期: 2007年 6 月 22 日 基层教学单位责任人签章:主管院长签章:前面的排版注意不要使这页跨页!切记切记!目 录1 设计目的与要求页码2 总体设计页码3 详细设计页码3.1功能模块设计页码3.2数据结构设计页码4调试分析 页码5 总结页码6 附录页码6 答辩记录(正文处留出适当空白) 页码7 指导教师意见(正文处留出十行空白) 页码1 .目的与要求目的:u 将理论教学中涉及到的知识点贯穿起来,对不同的数据类型、程序控制结构、数据结构作一比较和总结,结合设计题目进行综合性应用,对所学知识达到融会贯通的程度。利用面向过程的编程思想以及C的编程方法完成系统的设计;进一步培养学生综合应用C的各种编程知识和技巧进行Windows 应用程序编写的实际能力,包括:(1)对C基本语法的熟练掌握;(2)训练学生对一个实际应用系统进行综合分析、设计、编程及调试等的能力;(3)培养学生自主学习和独立创新的精神。要求:1) 对于给定的设计题目,如何进行分析,理清思路,并给出相应的数学模型。 2) 掌握自顶而下的设计方法,将大问题进行模块化,领会结构化程序设计的方法。3) 熟练掌握C语言的基本语法,灵活运用各种数据类型。4) 进一步掌握在集成环境下如何调试程序(单步调试,设置断点、观察表达式,分块调试)和修改程序。设计的具体内容:编写有一个程序,该程序输入职工工号和完成的产品数量,程序允许同一职工有多次输入,由程序对其完成的产品数量实现累计。程序按完成数量对他们排序,并确定他们的名次。按完成的产品数量由多到少的顺序,输出名次、同一名次的职工人数及他们的工号(工号由小到大顺序输出)。要求程序用有序链表存储数据信息。2 总体设计1准备.1)要求对序链表的使用具有较熟练的能力。2)用到数组、指针方面的重要知识。3)函数的循环连续使用。2概要设计.1,插入链表的节点先按照产品数量的多少排序(从多到少),如果产品的数量相等,就按照员工编号来排序(从小到大)2,如果产品数量相等的,他们的序号是相同的系统菜单 选择 1. 改变员工信息2.删除员工编号3. 退出系统4.查询 输入员工编号读取员工编号输入员工编号 实现产品数量累加调用删除函数输出员工工作量 系统菜单3 详细设计整个系统除了主函数外,另外还有多个函数,实现五大功能:输入功能、显示功能、排序功能、累加功能、插入功能、。各个函数的详细设计说明分别如下:1.主函数 main()利用无限次循环for(;)和swithch()实现各函数的调用,系统根据输入的数字选项来调用相应的函数。2.初始化函数 STUDENT *init()这是一个无参函数,里面只有一个语句,它的作用是使链表初始化,使head的值为NULL。比如:没有这个函数的话,在你没有输入任何数据的情况下,去执行显示功能的时候会显示一些乱码!3.输入记录函数 STUDENT *create()这是一个无参函数,用来执行职工工作量的输入,当职工为0时停止输入,函数结束后,带回一个指向链表头的指针head。算法:先声明一个首节点head,并将head-next设为NULL。每输入一个数据就声明一个新节点p,把p-next设为NULL,并且链接到之前列表的尾端。N-S流程图如下:head=NULLfor(;)指针p1指向新开辟的单元指针p1是否为空是否输入工号p1-num输出p1-num是否为0内存是否溢出 停止输入工作量输入返回 菜单 p1-productscount=atoi(temp); p1-next=NULL; 4.插入函数TS *InsertIntoLink(empnumber,productscount) 这是一个有参函数,形参有两个,一个是“链表头的指针”,一个是“待插入指针”,插入后会重新进行排序,并返回。算法:先将职工工作量进行排序,再插入一个新的结点。先用指针变量p2指向待插入的结点,p3指向第一个结点。如果p2-p1p1,则待插入的结点不应插在p3所指的结点之前。此时将p3后移,并使p2指向刚才p1所指的结点。重复以上的步骤,直到p2-p1=p3-p1为止。这时将p0指向的结点插到p1所指结点之前。如果插入位置为第一个结点之前,则将p2赋给head,将p3赋给p2-next。如果要插到表尾之后,应将p2赋给p3-next,NULL赋给p2-next。最后再调用排序的函数,重新排序.N-S流程图如下:P1=head, p2=new原来的链表是空表是否将p0所指当p2-p1p1, 以及p1所指向的不是表尾结的结点作为点唯一结点p2指向p1位置 p1向后移一个结点p2-p1=p3-p1是 否p1指向头结点p2-next=p1是否p1-next=NULLhead=p2p1-next=p2(插到表尾之后)p2 -next=p1 p2-next=p1(插到表头之前) (插到表中间)n=n+1;(结点加1)head=sort(hear);(重新排序)4 调试分析(1)刚开始没有那个初始化函数,程序运行后,没有输入任何数据就试得去执行显示功能,结果显示的是一些乱码!加入初始化函数后,这种现象也随之消失。(2)刚开始执行输入函数,输入多个职工的工作量,输完后执行,职工的工作量是按工号的反顺序显示的,试着在其中增加一些语句,希望能把工号按正常顺序显示.input employee number and the counts of productsexit: Double times 0 !112the head is null,so,the linklist head inserted success!return the head of the linklist! input employee number and the counts of productsexit: Double times ENTER216the head is NOT null,so,the linklist head inserted success!return the head of the linklist! input employee number and the counts of productsexit: Double times ENTER311the end of linklist inserted success!return the head of the linklist!input employee number and the counts of productsexit: Double times ENTER00 Pleas Make you choice1.Change Employee Information2.Delet Employee Number3.Print the linklist0.Exityour choice:3 output the result: order porductscount empnumber 1 16 2 1 16 5 2 12 1 2 12 4 3 11 3 4 9 6 Pleas Make you choice1.Change Employee Information2.Delet Employee Number3.Print the linklist0.Exityour choice:1Please Input you Employee Number And Products Count you are to change!the employee Number :5Searching for the number,Please wait.Find it!print the nod of temp: temp.empnumber= 5print the nod of temp: ductscount= 16print the nod of temp: temp.empnumber= 5print the nod of temp: ductscount= 16print the nod of temp: t2.empnumber= 5print the nod of temp: ductscount= 16befor Delete the temp node. output the result: order porductscount empnumber 1 16 2 1 16 5 2 12 1 2 12 4 3 11 3 4 9 6delets employee Number :5after delete the temp node. output the result: order porductscount empnumber 1 16 2 2 12 1 2 12 4 3 11 3 4 9 6Would you like to input more products count? if not,please type 0 your Input: 16Would you like to input more products count? if not,please type 0 your Input: 14Would you like to input more products count? if not,please type 0 your Input: 20Would you like to input more products count? if not,please type 0 your Input: 0the head is NOT null,so,the linklist head inserted success!return the head of the linklist! output the result: order porductscount empnumber 1 66 5 2 16 2 3 12 1 3 12 4 4 11 3 5 9 6 Pleas Make you choice1.Change Employee Information2.Delet Employee Number3.Print the linklist0.Exityour choice:2input the Employee Number you wanna delete:3delets employee Number :3 Pleas Make you choice1.Change Employee Information2.Delet Employee Number3.Print the linklist0.Exityour choice:3 output the result: order porductscount empnumber 1 66 5 2 16 2 3 12 1 3 12 4 4 9 6 Pleas Make you choice1.Change Employee Information2.Delet Employee Number3.Print the linklist0.Exityour choice:05 总 结经过几天的C语言课程设计,感觉自己收获不少!首先是:链表本来上课是没有上的,但这个课程设计里面主要都是用链表,因为要达到这样的功能,使用链表相当方便,但不容易理解,所以在这方面我很了很多的时间看课本和参考课外书,使C语言的知识强化了不少。其次,在做课程设计的过程中,发现了平时很多没有注意到的问题,例如:返回值函数和不返回值函数两者在主函数中的调用是不同的更重要的是,这次课程设计虽然花了我不少时间,但正是这些时间,让我见识到了C语言的重要性。由于这是第一次进行设计,写文档,难免会写得不好!6.附录代码设计.#include #include #include #include #include typedef struct STRUCT/*定义结构体 */ int empnumber;/*员工编号*/ int productscount; /*产品数量*/ struct STRUCT *next;/*指向下一个节点的指针*/TS;/*结构体的别名 */main() TS *CreateLink(TS*); /*声明创建链表的函数*/ TS *InsertIntoLink(); /*声明插入链表的函数*/ TS *DeletFromLink(); /*声明删除函数*/ TS *Search(); void print();/*声明打印链表的函数 */ TS *head; TS *temp; TS *t2; char s100; int empnumber=0; int productscount=0; int n; head=NULL; head=CreateLink(head); /*先创建空链表*/ temp=(TS*)malloc(sizeof(TS); t2=(TS*)malloc(sizeof(TS); while(1) /*一个可控制的循环*/ LOOP: printf(ntPleas Make you choicen); /*系统菜单*/ printf(1.Change Employee Informationn); /*改变员工信息*/ printf(2.Delet Employee Numbern); /*删除员工编号*/ printf(3.Print the linklistn); printf(0.Exitn); /*退出系统*/ printf(your choice:); gets(s); if(strcmp(s,1)!=0&strcmp(s,2)!=0&strcmp(s,3)!=0)return;/*如果不是1或者2选项,就退出系统*/ if(strcmp(s,1)=0) /*选择选项1,进行改变员工信息操作 */ printf(nPlease Input you Employee Number And Products Count you are to change!nthe employee Number :); gets(s); empnumber=atoi(s); /*输入员工编号*/ printf(nSearching for the number,Please wait.n); temp=Search(head,empnumber); printf(nprint the nod of temp: temp.empnumber= %d,temp-empnumber); printf(nprint the nod of temp: ductscount= %d,temp-productscount); /* */ if(temp=NULL)goto LOOP; else t2-empnumber=temp-empnumber; t2-productscount=temp-productscount; /* memcpy(t2,temp,sizeof(TS);*/ printf(nprint the nod of temp: temp.empnumber= %d,temp-empnumber); printf(nprint the nod of temp: ductscount= %d,temp-productscount); printf(nprint the nod of temp: t2.empnumber= %d,t2-empnumber); printf(nprint the nod of temp: ductscount= %d,t2-productscount);/*/ t2-next=NULL; printf(nbefor Delete the temp node.n); print(head); head=DeletFromLink(head,t2-empnumber); printf(nafter delete the temp node.n); print(head); productscount+=t2-productscount; while(1) /*改循环实现产品数量累加计算*/ printf(Would you like to input more products count? if not,please type 0n your Input: ); gets(s); if(strcmp(s,0)!=0) productscount+=atoi(s);/*累加操作*/ else break; /*停止累加*/ t2-productscount=productscount; head=InsertIntoLink(head,t2-empnumber,t2-productscount);/* 把员工编号和产品数量插入到链表中*/ print(head); /*打印改链表*/ else if(strcmp(s,2)=0) printf(input the Employee Number you wanna delete:); /*选择选项2,进行了删除员工信息操作*/ gets(s); empnumber=atoi(s); /*读取员工编号*/ /*Search(head,empnumber); */ head=DeletFromLink(head,empnumber); /*调用删除函数*/ else print(head); TS *CreateLink(TS *head) /*创建链表函数 */ char temp100; TS *p1; p1=(TS*)malloc(sizeof(TS); /*为一个链表节点分配存储空间*/ printf( input employee number and the counts of productsn); printf(exit: Double times 0 !n); /*两次输入0,表示退出*/ gets(temp); p1-empnumber=atoi(temp); /*输入员工编号*/ gets(temp); p1-productscount=atoi(temp);/*输入产品数量*/ p1-next=NULL; /*链表节点的尾指针赋值为NULL*/ while(p1-empnumber0)/*当输入的员工编号不为0*/ /*if(head=NULL)head=p1;第一次插入,插在表头*/ head=InsertIntoLink(head,p1-empnumber,p1-productscount);/*调用插入函数,进行节点插入*/ p1=(TS*)malloc(sizeof(TS); /*为p1节点分配存储空间*/ printf( input employee number and the counts of productsn); printf(exit: Double times ENTERn); gets(temp); p1-empnumber=atoi(temp); /*为p1的成员变量empnumber赋值*/ gets(temp); p1-productscount=atoi(temp); /*为p1的成员变量赋值*/ p1-next=NULL; return head; /*返回首指针*/TS *InsertIntoLink(TS* head,int empnumber,int productscount) /*插入函数,有序插入*/ TS *p1,*p2,*p3; p1=(TS*)malloc(sizeof(TS); /*新建一个节点*/ p1-empnumber=empnumber; /*为节点赋值*/ p1-productscount=productscount; p2=head; /*p2指向首节点*/ if(head=NULL) /*首节点为空 */ head=p1;p1-next=NULL;/*新节点插入在表头 */ printf(the head is null,so,the linklist head inserted success!n); else /*首节点不为空 */ while(productscountproductscount&p2-next!=NULL) /*插入产品数量少于当前节点的产品数量*/ p3=p2; p2=p2-next; /*指针下移,继续搜索*/ if(productscount=p2-productscount) if(productscount=p2-productscount) while(productscount=p2-productscount&empnumberp2-empnumber&p2-next!=NULL) /*员工编号从小到大排序,如果要插入的员工编号比当前节点大,就继续往下搜索*/ p3=p2; p2=p2-next; if(head=p2) /*插在表头*/ head=p1; p1-next=p2; printf(the head is NOT null,so,the linklist head inserted success!n); else /*插在表中间*/ p3-next=p1; p1-next=p2; printf(the midle of linklist inserted success!n); else /*插在表尾*/ p2-next=p1; p1-next=NULL; printf(the end of linklist inserted success!n); printf(return the head of the linklist!n); return(head);void print(TS *he
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 疲劳裂纹扩展与寿命预报-洞察及研究
- 2025年文化场馆建设项目社会稳定风险评估与风险应对策略实施效果分析实施报告
- 自考专业(护理)试题预测试卷及参考答案详解一套
- 重难点解析青海省德令哈市中考数学真题分类(平行线的证明)汇编综合测评练习题
- 2025年工业互联网平台TEE在工业物联网安全生态构建中的应用案例分析报告
- 年产3500台固态电池验证车型项目可行性研究报告
- 环保公司薪酬发放管理规定
- 环保公司危机公关管理规定
- 自考专业(计算机网络)常考点试卷含完整答案详解(夺冠)
- 综合解析人教版8年级数学上册《轴对称》章节测评练习题(含答案详解)
- 2025广东省中考英语真题(原卷版)
- 2025年四川省投资集团有限责任公司招聘笔试备考题库含答案详解
- 变电站防恐课件
- 2025年关于村支部书记的面试题及答案
- 2025湖南非全日制用工劳动合同范本2
- 2025年农村商业银行招聘笔试真题及答案(可下载)
- 熏蒸药品管理办法
- 收银系统操作培训
- 卓越幼儿园教师健康专题培训课件
- 个股期权培训课件
- 临时起搏器安置术的护理
评论
0/150
提交评论