版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、一、课程设计的内容将所选的题目的内容copy过来,包括功能要求等等。不记得可以看附录。字体是楷体,注意排版,不要让下一页(老师签名那页)跨页!职工工作量统计系统编写有一个程序,该程序输入职工工号和完成的产品数量,程序允许同一职工有多次输入,由程序对其完成的产品数量实现累计。程序按完成数量对他们排序,并确定他们的名次。按完成的产品数量由多到少的顺序,输出名次、同一名次的职工人数及他们的工号(工号由小到大顺序输出)。要求程序用有序链表存储数据信息。二、课程设计的要求与数据1、进一步掌握和利用c语言进行程设计的能力;2、进一步理解和运用结构化程序设计的思想和方法;3、初步掌握开发一个小型实用系统的基
2、本方法;4、学会调试一个较长程序的基本方法;5、学会利用流程图或n-s图表示算法;6、掌握书写程序设计开发文档的能力。三、课程设计应完成的工作1、编写完成相应题目的程序;2、编写课程设计报告,课程设计报告的内容应包括以下6个部分:1) 需求分析:包括设计题目、设计要求以及系统功能需求分析;2) 总体设计:包括系统总体设计框架和系统功能模块图;3) 详细设计:包括主要功能模块的算法设计思路以及对应的工作流程图;4) 调试分析过程描述:包括测试数据、测试输出结果,以及对程序调试过程中存在问题的思考(列出主要问题的出错现象、出错原因、解决方法及效果等,适当的包含结果截图);5) 总结:课程设计完成了
3、哪些功能,有没有什么扩展功能?还有哪些地方需要改进?课程设计过程中的学习体会与收获、对本次课程设计的认识以及自己的建议等内容; 6) 附录:主要源程序代码,含必要的注释。3、答辩:在实验室建立程序运行的环境,并在指导教师的监督下,独立解 决问题、运行程序和回答教师提出的问题。四、课程设计进程安排序号设计各阶段内容地点起止日期1下达任务书,说明设计要求;收集资料实验3#5176.182总体方案设计、详细设计实验3#5176.193编写程序,调试分析实验3#5176.204撰写报告并上交,答辩实验3#5176.21五、应收集的资料及主要参考文献注意参考文献的格式要求,依照下面的两个的格式填写,可以
4、是网页,书,杂志, 合计最少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.
5、1功能模块设计页码3.2数据结构设计页码4调试分析 页码5 总结页码6 附录页码6 答辩记录(正文处留出适当空白) 页码7 指导教师意见(正文处留出十行空白) 页码1 .目的与要求目的:u 将理论教学中涉及到的知识点贯穿起来,对不同的数据类型、程序控制结构、数据结构作一比较和总结,结合设计题目进行综合性应用,对所学知识达到融会贯通的程度。利用面向过程的编程思想以及c的编程方法完成系统的设计;进一步培养学生综合应用c的各种编程知识和技巧进行windows 应用程序编写的实际能力,包括:(1)对c基本语法的熟练掌握;(2)训练学生对一个实际应用系统进行综合分析、设计、编程及调试等的能力;(3)培养
6、学生自主学习和独立创新的精神。要求:1) 对于给定的设计题目,如何进行分析,理清思路,并给出相应的数学模型。 2) 掌握自顶而下的设计方法,将大问题进行模块化,领会结构化程序设计的方法。3) 熟练掌握c语言的基本语法,灵活运用各种数据类型。4) 进一步掌握在集成环境下如何调试程序(单步调试,设置断点、观察表达式,分块调试)和修改程序。设计的具体内容:编写有一个程序,该程序输入职工工号和完成的产品数量,程序允许同一职工有多次输入,由程序对其完成的产品数量实现累计。程序按完成数量对他们排序,并确定他们的名次。按完成的产品数量由多到少的顺序,输出名次、同一名次的职工人数及他们的工号(工号由小到大顺序
7、输出)。要求程序用有序链表存储数据信息。2 总体设计1准备.1)要求对序链表的使用具有较熟练的能力。2)用到数组、指针方面的重要知识。3)函数的循环连续使用。2概要设计.1,插入链表的节点先按照产品数量的多少排序(从多到少),如果产品的数量相等,就按照员工编号来排序(从小到大)2,如果产品数量相等的,他们的序号是相同的系统菜单 选择 1. 改变员工信息2.删除员工编号3. 退出系统4.查询 输入员工编号读取员工编号输入员工编号 实现产品数量累加调用删除函数输出员工工作量 系统菜单3 详细设计整个系统除了主函数外,另外还有多个函数,实现五大功能:输入功能、显示功能、排序功能、累加功能、插入功能、
8、。各个函数的详细设计说明分别如下:1.主函数 main()利用无限次循环for(;)和swithch()实现各函数的调用,系统根据输入的数字选项来调用相应的函数。2.初始化函数 student *init()这是一个无参函数,里面只有一个语句,它的作用是使链表初始化,使head的值为null。比如:没有这个函数的话,在你没有输入任何数据的情况下,去执行显示功能的时候会显示一些乱码!3.输入记录函数 student *create()这是一个无参函数,用来执行职工工作量的输入,当职工为0时停止输入,函数结束后,带回一个指向链表头的指针head。算法:先声明一个首节点head,并将head-nex
9、t设为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) 这是一个有参函数,形参有两个,一个是“链表头的指针”,一个是“待插入指针”,插入后会重新进行排序,并返回。算法:先将职工工作量进行
10、排序,再插入一个新的结点。先用指针变量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所指向的不是表尾结的结点作为
11、点唯一结点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)刚开始执行输入函数,输入多个职工的工作量,输完后执行,职工的工作量是按工号的反顺序显示的,试着在其中增加一些语
12、句,希望能把工号按正常顺序显示.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 insert
13、ed 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 employe
14、e 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 emplo
15、yee 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 o
16、f 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
17、 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 coun
18、t? 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
19、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 ple
20、as make you choice1.change employee information2.delet employee number3.print the linklist0.exityour choice:05 总 结经过几天的c语言课程设计,感觉自己收获不少!首先是:链表本来上课是没有上的,但这个课程设计里面主要都是用链表,因为要达到这样的功能,使用链表相当方便,但不容易理解,所以在这方面我很了很多的时间看课本和参考课外书,使c语言的知识强化了不少。其次,在做课程设计的过程中,发现了平时很多没有注意到的问题,例如:返回值函数和不返回值函数两者在主函数中的调用是不同的更重要的是,这次
21、课程设计虽然花了我不少时间,但正是这些时间,让我见识到了c语言的重要性。由于这是第一次进行设计,写文档,难免会写得不好!6.附录代码设计.#include #include #include #include #include typedef struct struct/*定义结构体 */ int empnumber;/*员工编号*/ int productscount; /*产品数量*/ struct struct *next;/*指向下一个节点的指针*/ts;/*结构体的别名 */main() ts *createlink(ts*); /*声明创建链表的函数*/ ts *insertint
22、olink(); /*声明插入链表的函数*/ 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) /*一个可控制的循
23、环*/ 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或
24、者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 te
25、mp: 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,te
26、mp-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=de
27、letfromlink(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 br
28、eak; /*停止累加*/ 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,em
29、pnumber); */ 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)
30、; 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); /*为p
31、1节点分配存储空间*/ 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 empnumbe
32、r,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)
33、; 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) /*员工编号从小到大排序,如果要插入的员工编号比当前节点大,就继续往
34、下搜索*/ 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年西安市疾控中心招聘《预防医学》试题附答案
- 高三思想政治“文化传承与文化创新”单元复习教学设计
- 高三政治教学设计:和平与发展主题下的核心素养培育与真题情境构建
- 初中地理八年级《中国的疆域》教学设计
- DBJ50-T-381-2021 山地建筑工程逆作法技术标准
- 财会岗事业单位面试综合管理岗事业单位面试易错题题库及参考答案
- 综合岗事业单位面试2026考题汇编及解析
- 财会岗事业单位面试面试真题题库及解析2026
- 肺癌骨转移诊疗专家共识(2026版)
- 国铁集团铁路工程架梁安全作业标准化指导手册
- 2026年N1叉车司机模拟考试题带答案
- 2026新型电力系统-AIAgent智能体体系技术与应用研究报告
- 2026年特钢行业洞察报告及未来五至十年发展趋势报告
- 2027(苏教版)科学(新教材)四年级上册全册单元测试(含解析)
- 农机冬季安全隐患排查
- 2026年四川省成都市中小学教师招聘考试真题解析含答案
- 2026年6月英语四级真题(第一套)附答案
- 2026年四川省拟任县处级领导干部理论(任职资格考试)全真模拟试题及答案
- 中央国家药品监督管理局药品和医疗器械审评检查京津冀分中心华中分中心西南分中心2025年招聘27人笔试历年参考题库附带答案详解(5卷)
评论
0/150
提交评论