版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、程序设计报告设计者:肖昊班级序号:055071-27学号:*指导老师:*C语言程序设计编程实践是学习C语言程序设计的一重要环节,为提高学生程序设计能力,通过课堂和上机实践练习使学生的程序设计能力上一台阶。通过前四单元温顾而知新、庖丁解牛、举一反三、熟能生巧等过程的练习设计下面一个完整的程序1.题目要求设计“机房机位预约模拟系统”要求:20台机器,从早8点到晚8点,每两个小时一个时间段。需要实现功能:1,查询,根据输入时间,输出机位信息。2,即为预定,根据输入的日期和时间段查询是否有空机位,若有则预约,若无则提供最近空机时间段。另:若用户要求在非空时间上机,则将用户信息插入该时间段的等待列表.3
2、,退出预定,根据输入的时间,撤销该时间的预定。4,查询是否有等待的信息,若有则按顺序显示联系方式,若无则显示提示信息。2需求分析根据题目要求在程序中需实现查询,预定,排队等功能的操作,所以需要建立相应的模块来实现;另外还需提供键盘式选择菜单实现功能,在运行时达到所要目的。3总体设计整个系统可分为3个模块查询模块预定模块取消模块机房机位预约模拟、I系统查询模块厂预定模块、查询模块厂预定模块、I)取消模块、,)详细设计主函数比较简洁,只提供输入、功能处理和输出部分的函数调用。main()inti;for(i=0;i=8&nnext!=NULL;Rem=Rem-next)if(strcmp(Rem-
3、data,Infor)=0)break;if(Rem-locat!=0)printf(Thecomputernumberis%dn,Rem-locat);elseprintf(对不起.你依旧在等待列表中或者没有预定”);elseprintf(”错误,请再次输入An);voidinquir()intn;printf(输入想要查询的时间(24hours820oclock,include8oclock)*);scanf(%d,&n);if(n=8&n20)n=S(n);if(TimeQueuen.CNum=8&n20)n=S(n);if(TimeQueuen.CNumlocat=1;strcpy(R
4、em-data,Infor);Rem-next=NULL;TimeQueuen.first=Rem;TimeQueuen.last=Rem;TimeQueuen.CNum+;printf(”成功预定n);elseRem=(structnode*)malloc(sizeof(structnode);strcpy(Rem-data,Infor);Rem-next=NULL;p=TimeQueuen.last;Rem-locat=TimeQueuen.CNum+1;printf(%d,Rem-locat);TimeQueuen.last=Rem;p-next=Rem;TimeQueuen.CNum+
5、;printf(”成功预定n);elseprintf(”没有空余机位!);elseprintf(”错误请再次输入An);voidwaiting()intn;charInfor10;structnode*Rem;structnode*p;printf(”请输入想要排队的时间n);scanf(%d,&n);if(n=8&n=MAX)printf(请输入你的学号n);scanf(%s,Infor);if(TimeQueuen.CNum)=MAX)Rem=(structnode*)malloc(sizeof(structnode);strcpy(Rem-data,Infor);Rem-next=NUL
6、L;Rem-locat=0;p=TimeQueuen.last;TimeQueuen.last=Rem;p-next=Rem;TimeQueuen.middle=Rem;TimeQueuen.CNum+;printf(”成功排队n);elseRem=(structnode*)malloc(sizeof(structnode);strcpy(Rem-data,Infor);Rem-next=NULL;Rem-locat=0;p=TimeQueuen.last;TimeQueuen.last=Rem;p-next=Rem;TimeQueuen.CNum+;printf(”成功排队n);elsepr
7、intf(”有空余机位,无须等待n);elseprintf(错误.再次输入An);voidcancel()intn;inti;charInfor10;structnode*Rem;structnode*q;structnode*p;printf(”请输入预定的时间n);scanf(%d,&n);if(n=8&nnext,i+)if(strcmp(Rem-data,Infor)=0)break;if(iMAX)if(Rem-next=NULL)q-next=NULL;TimeQueuen.last=q;free(Rem);TimeQueuen.CNum-;printf(Succeedtooutt
8、hequeue!n);elseq-next=Rem-next;free(Rem);TimeQueuen.CNum-;printf(Succeedtooutthequeue!n);elseif(TimeQueuen.CNumMAX)TimeQueuen.middle-locat=Rem-locat;TimeQueuen.middle=TimeQueuen.middle-next;if(i=1)TimeQueuen.first=Rem-next;elseq-next=Rem-next;free(Rem);TimeQueuen.CNum-;printf(成功取消预定!n);附录源代码:#includ
9、evstdio.h#include#include#defineLENGTH6#defineMAX20#defineS(r)(r-8)/2#defineNULL0structnodeintlocat;chardata10;structnode*next;structnode*head;structcellintCNum;structnode*first;structnode*middle;structnode*last;TimeQueueLENGTH;voidInquir()intn;charInfor10;structnode*Rem;printf(输入查询时间(24hours820oclo
10、ck,include8oclock)n);scanf(%d,&n);if(n=8&nnext!=NULL;Rem=Rem-next)if(strcmp(Rem-data,Infor)=0)break;if(Rem-locat!=0)printf(Thecomputernumberis%dn,Rem-locat);elseprintf(对不起.你依旧在等待列表中或者没有预定”);elseprintf(”错误,请再次输入An);voidinquir()intn;printf(输入想要查询的时间(24hours820oclock,include8oclock)n);scanf(%d,&n);if(n
11、=8&n20)n=S(n);if(TimeQueuen.CNum=8&n20)n=S(n);if(TimeQueuen.CNumlocat=1;strcpy(Rem-data,Infor);Rem-next=NULL;TimeQueuen.first=Rem;TimeQueuen.last=Rem;TimeQueuen.CNum+;printf(”成功预定n);elseRem=(structnode*)malloc(sizeof(structnode);strcpy(Rem-data,Infor);Rem-next=NULL;p=TimeQueuen.last;Rem-locat=TimeQu
12、euen.CNum+1;printf(%d,Rem-locat);TimeQueuen.last=Rem;p-next=Rem;TimeQueuen.CNum+;printf(”成功预定n);elseprintf(”没有空余机位!);elseprintf(”错误请再次输入An);voidwaiting()intn;charInfor10;structnode*Rem;structnode*p;printf(”请输入想要排队的时间n);scanf(%d,&n);if(n=8&n=MAX)printf(请输入你的学号n);scanf(%s,Infor);if(TimeQueuen.CNum)=MA
13、X)Rem=(structnode*)malloc(sizeof(structnode);strcpy(Rem-data,Infor);Rem-next=NULL;Rem-locat=0;p=TimeQueuen.last;TimeQueuen.last=Rem;p-next=Rem;TimeQueuen.middle=Rem;TimeQueuen.CNum+;printf(”成功排队n);elseRem=(structnode*)malloc(sizeof(structnode);strcpy(Rem-data,Infor);Rem-next=NULL;Rem-locat=0;p=TimeQ
14、ueuen.last;TimeQueuen.last=Rem;p-next=Rem;TimeQueuen.CNum+;printf(”成功排队n);elseprintf(”有空余机位,无须等待n);elseprintf(错误.再次输入An);voidcancel()intn;inti;charInfor10;structnode*Rem;structnode*q;structnode*p;printf(”请输入预定的时间n);scanf(%d,&n);if(n=8&nnext,i+)if(strcmp(Rem-data,Infor)=0)break;if(iMAX)if(Rem-next=NU
15、LL)q-next=NULL;TimeQueuen.last=q;free(Rem);TimeQueuen.CNum-;printf(Succeedtooutthequeue!n);elseq-next=Rem-next;free(Rem);TimeQueuen.CNum-;printf(Succeedtooutthequeue!n);elseif(TimeQueuen.CNumMAX)TimeQueuen.middle-locat=Rem-locat;TimeQueuen.middle=TimeQueuen.middle-next;if(i=1)TimeQueuen.first=Rem-ne
16、xt;elseq-next=Rem-next;free(Rem);TimeQueuen.CNum-;printf(”成功取消预定!n);elseprintf(”错误,请再次输入An);voidinquir_waiting()intn;structnode*q;printf(查询其他等待者的预定时间n);scanf(%d,&n);if(n=8&nMAX)printf(”等待列表are:n);q=TimeQueuen.middle;for(;q-next!=NULL;q=q-next)printf(%sn,q-data);printf(%sn,TimeQueuen.last-data);elseprintf(这个时间段没有预定者n);elseprintf(”错误。请再次输入.n);main()inti;for(i=0;iLENGTH;i+)TimeQueuei.CNum=0;TimeQueuei.first=NULL;TimeQueuei.middle=NULL;TimeQueuei.last=NULL;while(1)printf(”请输
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 团队核心电源标语
- 施工员试题预测(三)
- 公司管理设计方案(2篇)
- 酒店筹开筹建运作方案(2篇)
- 农村电子商务运营方案调研报告(2篇)
- 2023-2024学年辽宁省辽阳二中协作校八年级(下)期中数学试卷(含解析)
- 2022年公务员考试宁德市寿宁县《行政职业能力测验》深度预测试题含解析
- 《行政职业能力测验》安国市2022年公务员考试考前冲刺预测试卷含解析
- 《行政职业能力测验》2022年公务员考试大安市预测密卷含解析
- 青海省果洛藏族自治州玛多县2022年公务员考试《行政职业能力测验》全真模拟试题含解析
- 2023信息安全技术人工智能计算平台安全框架
- 国家开放大学《心理与健康》形考任务1-3参考答案
- 外出申请单标准
- 相声《好学生与坏学生》
- 离职表-(最终版)
- 5国际贸易的现代与当代理论(II)解析
- (医学课件)围手术期管理.ppt
- 直系亲属关系证明
- 土木工程教学楼毕业设计计算书
- 2018年新版一级建造师市政实务word版
- 技术经济学概论课后习题答案ppt课件.ppt
评论
0/150
提交评论