


版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、程序设计报告设计者:肖昊班级序号:055071-27学号:20071003651指导老师:刘文中C语言程序设计编程实践是学习C语言程序设计的一重要环节,为提高学生程序设计能力,通过课堂和上机实践练习使学生的程序设计能力上一台阶。通过前四单元温顾而知新、庖丁解牛、举一反三、熟能生巧等过程的练习设计下面一个完整的程序1.题目要求设计“机房机位预约模拟系统”要求:20台机器,从早8点到晚8点,每两个小时一个时间段。需要实现功能:1, 查询,根据输入时间,输出机位信息。2, 即为预定,根据输入的日期和时间段查询是否有空机位,若有则预约,若无则提供最近空机时间段。另:若用户要求在非空时间上机,则将用户信
2、息插入该时间段的等待列表.3, 退出预定,根据输入的时间,撤销该时间的预定。4, 查询是否有等待的信息,若有则按顺序显示联系方式,若无则显示提示信息。2需求分析根据题目要求在程序中需实现查询,预定,排队等功能的操作,所以需要建立相应的模块来实现;另外还需提供键盘式选择菜单实现功能,在运行时达到所要目的。3总体设计整个系统可分为3个模块查询模块预定模块取消模块机房机位预约模拟系统查询模块1预定模块取消模块)I)L,详细设计主函数比较简洁,只提供输入、功能处理和输出部分的函数调用。main()inti;for(i=0;i<LENGTH;i+)TimeQueuei.CNum=0;TimeQue
3、uei.first=NULL;TimeQueuei.middle=NULL;TimeQueuei.last=NULL;while(1)printf("请输入序号!:n");printf("1.查询预定的机位2.查询空机位3.预定4.取消预定5.等待列表6.查询等待者列表0.退出n");scanf("%d”,&i);switch(i)case1:Inquir();break;case2:inquir();break;case3:booking();break;case4:cancel();break;case5:waiting();bre
4、ak;case6:inquir_waiting();break;case0:exit(0);default:printf("errorn");voidInquir()(intn;charInfor10;structnode*Rem;printf("输入查询时间(24hours820o'clock,include8o'clock)n");scanf("%d”,&n);if(n>=8&&n<20)n=S(n);printf("请输入学号n");scanf("%s&qu
5、ot;,Infor);Rem=TimeQueuen.first;for(;Rem->next!=NULL;Rem=Rem->next)if(strcmp(Rem->data,Infor)=0)break;if(Rem->locat!=0)printf("Thecomputernumberis%dn",Rem->locat);elseprintf("对不起.你依旧在等待列表中或者没有预定");elseprintf("错误,请再次输入.n");voidinquir()intn;printf("输入想
6、要查询的时间(24hours820o'clock,include8o'clock)n");scanf("%d”,&n);if(n>=8&&n<20)n=S(n);if(TimeQueuen.CNum<MAX)printf("Thereare%demptycomputer!n”,MAX-TimeQueuen.CNum);elseprintf("对不起.没有空余机位n");elseprintf("错误,再次输入.n");预定模块voidbooking()intn;char
7、Infor10;structnode*Rem;structnode*p;printf("输入想要预定的时间n");scanf("%d",&n);if(n>=8&&n<20)n=S(n);if(TimeQueuen.CNum<MAX)printf("请输入你的学号n");scanf("%s”,Infor);if(TimeQueuen.first=NULL)Rem=(structnode*)malloc(sizeof(structnode);Rem->locat=1;strcpy(
8、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=TimeQueuen.CNum+1;printf("%d”,Rem->locat);Time
9、Queuen.last=Rem;p->next=Rem;TimeQueuen.CNum+;printf("成功预定n");elseprintf("没有空余机位!");elseprintf("错误.请再次输入.n");voidwaiting()intn;charInfor10;structnode*Rem;structnode*p;printf("请输入想要排队的时间n");scanf("%d”,&n);if(n>=8&&n<20)n=S(n);if(TimeQue
10、uen.CNum>=MAX)printf("请输入你的学号n");scanf("%s",Infor);if(TimeQueuen.CNum)=MAX)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
11、("成功排队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");elseprintf("有空余机位,无须等待n");elseprintf("错误.再次输入.n");取消void
12、cancel()(intn;inti;charInfor10;structnode*Rem;structnode*q;structnode*p;printf("请输入预定的时间n");scanf("%d”,&n);if(n>=8&&n<20)printf("PleaseinputyourNo.!n");scanf("%s",Infor);n=S(n);Rem=TimeQueuen.first;q=Rem;for(i=1;q=Rem,Rem=Rem->next,i+)if(strcmp
13、(Rem->data,Infor)=0)break;if(i>MAX)if(Rem->next=NULL)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.CNum>MAX)TimeQu
14、euen.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");附录源代码:#include<stdio.h>#include<stdlib.h>#include<string.h>#defineLENGTH6#defineMAX20
15、#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("输入查询时间(24hours820o'clock,include8o'clock)n");scanf(&
16、quot;%d”,&n);if(n>=8&&n<20)n=S(n);printf("请输入学号n");scanf("%s",Infor);Rem=TimeQueuen.first;for(;Rem->next!=NULL;Rem=Rem->next)if(strcmp(Rem->data,Infor)=0)break;if(Rem->locat!=0)printf("Thecomputernumberis%dn",Rem->locat);elseprintf("
17、;对不起.你依旧在等待列表中或者没有预定");elseprintf("错误,请再次输入.n");voidinquir()intn;printf("输入想要查询的时间(24hours820o'clock,include8o'clock)n");scanf("%d",&n);if(n>=8&&n<20)n=S(n);if(TimeQueuen.CNum<MAX)printf("Thereare%demptycomputer!n”,MAX-TimeQueuen.C
18、Num);elseprintf("对不起.没有空余机位n");elseprintf("错误,再次输入.n");voidbooking()intn;charInfor10;structnode*Rem;structnode*p;printf("输入想要预定的时间n");scanf("%d",&n);if(n>=8&&n<20)n=S(n);if(TimeQueuen.CNum<MAX)printf("请输入你的学号n");scanf("%s&qu
19、ot;,Infor);if(TimeQueuen.first=NULL)Rem=(structnode*)malloc(sizeof(structnode);Rem->locat=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);Re
20、m->next=NULL;p=TimeQueuen.last;Rem->locat=TimeQueuen.CNum+1;printf("%d",Rem->locat);TimeQueuen.last=Rem;p->next=Rem;TimeQueuen.CNum+;printf("成功预定n");elseprintf("没有空余机位!");elseprintf("错误.请再次输入.n");voidwaiting()intn;charInfor10;structnode*Rem;structn
21、ode*p;printf("请输入想要排队的时间n");scanf("%d”,&n);if(n>=8&&n<20)n=S(n);if(TimeQueuen.CNum>=MAX)printf("请输入你的学号n");scanf("%s”,Infor);if(TimeQueuen.CNum)=MAX)Rem=(structnode*)malloc(sizeof(structnode);strcpy(Rem->data,Infor);Rem->next=NULL;Rem->loca
22、t=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+;
23、printf("成功排队n");elseprintf("有空余机位,无须等待n");elseprintf("错误.再次输入.n");voidcancel()intn;inti;charInfor10;structnode*Rem;structnode*q;structnode*p;printf("请输入预定的时间n");scanf("%d”,&n);if(n>=8&&n<20)printf("PleaseinputyourNo.!n");scanf(
24、"%s",Infor);n=S(n);Rem=TimeQueuen.first;q=Rem;for(i=1;q=Rem,Rem=Rem->next,i+)if(strcmp(Rem->data,Infor)=0)break;if(i>MAX)if(Rem->next=NULL)q->next=NULL;TimeQueuen.last=q;free(Rem);TimeQueuen.CNum-;printf("Succeedtooutthequeue!n");elseq->next=Rem->next;free(Re
25、m);TimeQueuen.CNum-;printf("Succeedtooutthequeue!n");elseif(TimeQueuen.CNum>MAX)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");elseprintf("错误,请再次输入.n");vo
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025版房地产抵押权预售合同范本
- 2025版房屋买卖三方合同定金及房屋交易合同解除后争议解决机制协议
- 二零二五年度绿色能源运输服务-煤矸石专项运输合同
- 二零二五版保密协议书范本(含专利申请信息)
- 二零二五年度城市地下综合管廊电缆敷设及安全防护合同
- 二零二五年度工矿产品风险管理服务合同范本
- 二零二五年会议室装修合同-会议室装修施工质量保证协议
- 二零二五年度土地经营权买卖合同打印模板
- 2025版房地产合作开发项目消防安全协议
- 岩石力学课件-侧压力
- GB/T 9871-2008硫化橡胶或热塑性橡胶老化性能的测定拉伸应力松弛试验
- GB/T 26480-2011阀门的检验和试验
- GB/T 19861-2005丙烯酸系阴离子交换树脂强碱基团、弱碱基团和弱酸基团交换容量测定方法
- GB/T 11085-1989散装液态石油产品损耗
- GB 30000.3-2013化学品分类和标签规范第3部分:易燃气体
- 《材料力学》说课-课件
- (完整版)沪教牛津版小学一至六年级英语单词汇总(最新)
- JJF 1587-2016 数字多用表校准规范-(高清现行)
- 完整课件-西方经济学下册(第二版)
- 机械制图教学通用课件(全套)
- 天星择日的基本原理
评论
0/150
提交评论