C语言课程设计报告—机房机位预约模拟系统.doc_第1页
C语言课程设计报告—机房机位预约模拟系统.doc_第2页
C语言课程设计报告—机房机位预约模拟系统.doc_第3页
C语言课程设计报告—机房机位预约模拟系统.doc_第4页
C语言课程设计报告—机房机位预约模拟系统.doc_第5页
免费预览已结束,剩余11页可下载查看

下载本文档

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

文档简介

程序设计报告设计者:肖昊班级序号:055071-27学号:20071003651指导老师:刘文中C语言程序设计编程实践是学习C语言程序设计的一重要环节,为提高学生程序设计能力,通过课堂和上机实践练习使学生的程序设计能力上一台阶。通过前四单元温顾而知新、庖丁解牛、举一反三、熟能生巧等过程的练习设计下面一个完整的程序1. 题目要求设计“机房机位预约模拟系统”要求:20台机器,从早8点到晚8点,每两个小时一个时间段。 需要实现功能: 1,查询,根据输入时间,输出机位信息。 2,即为预定,根据输入的日期和时间段查询是否有空机位,若有则预约,若无则提供最近空机时间段。另:若用户要求在非空时间上机,则将用户信息插入该时间段的等待列表. 3,退出预定,根据输入的时间,撤销该时间的预定。 4,查询是否有等待的信息,若有则按顺序显示联系方式,若无则显示提示信息。 2需求分析根据题目要求在程序中需实现查询,预定,排队等功能的操作,所以需要建立相应的模块来实现;另外还需提供键盘式选择菜单实现功能,在运行时达到所要目的。 3总体设计整个系统可分为3个模块 查询模块 预定模块 取消模块机房机位预约模拟系统查询模块预定模块取消模块 详细设计 主函数比较简洁,只提供输入、功能处理和输出部分的函数调用。 显示一系列功能选择输入n,判断m 是否是0到6?根据n值调用各功能模块函数结束N开始main() int i; for(i=0;i=8&nnext!=NULL;Rem=Rem-next) if(strcmp(Rem-data,Infor)=0)break; if(Rem-locat!=0) printf(The computer number is %dn,Rem-locat); else printf(对不起.你依旧在等待列表中或者没有预定); else printf(错误,请再次输入.n); void inquir() int n; printf(输入想要查询的时间(24 hours 820oclock,include 8 oclock)n); scanf(%d,&n); if(n=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); else Rem=(struct node *)malloc(sizeof(struct node); 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+; printf(成功预定n); else printf(没有空余机位!); else printf(错误.请再次输入.n); void waiting() int n; char Infor10; struct node *Rem; struct node *p; printf(请输入想要排队的时间n); scanf(%d,&n); if(n=8&n=MAX) printf(请输入你的学号n); scanf(%s,Infor); if(TimeQueuen.CNum)=MAX) Rem=(struct node *)malloc(sizeof(struct node); 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); else Rem=(struct node *)malloc(sizeof(struct node); strcpy(Rem-data,Infor); Rem-next=NULL; Rem-locat=0; p=TimeQueuen.last; TimeQueuen.last=Rem; p-next=Rem; TimeQueuen.CNum+; printf(成功排队n); else printf(有空余机位,无须等待n); else printf(错误.再次输入.n); 取消模块 开始输入预定时间 判断是否预定与排队成功取消预定结束N void cancel() int n; int i; char Infor10; struct node *Rem; struct node *q; struct node *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(Succeed to out the queue!n); else q-next=Rem-next; free(Rem); TimeQueuen.CNum-; printf(Succeed to out the queue!n); else if(TimeQueuen.CNumMAX) TimeQueuen.middle-locat=Rem-locat; TimeQueuen.middle=TimeQueuen.middle-next; if(i=1) TimeQueuen.first=Rem-next; else q-next=Rem-next; free(Rem); TimeQueuen.CNum-; printf(成功取消预定!n);附录源代码:#include #include #include #define LENGTH 6 #define MAX 20 #define S(r) (r-8)/2 #define NULL 0 struct node int locat; char data10; struct node *next; ; struct node *head; struct cell int CNum; struct node *first; struct node *middle; struct node *last; TimeQueueLENGTH; void Inquir() int n; char Infor10; struct node *Rem; printf(输入查询时间(24 hours 820 oclock,include 8oclock)n); scanf(%d,&n); if(n=8&nnext!=NULL;Rem=Rem-next) if(strcmp(Rem-data,Infor)=0)break; if(Rem-locat!=0) printf(The computer number is %dn,Rem-locat); else printf(对不起.你依旧在等待列表中或者没有预定); else printf(错误,请再次输入.n); void inquir() int n; printf(输入想要查询的时间(24 hours 820oclock,include 8 oclock)n); scanf(%d,&n); if(n=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); else Rem=(struct node *)malloc(sizeof(struct node); 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+; printf(成功预定n); else printf(没有空余机位!); else printf(错误.请再次输入.n); void waiting() int n; char Infor10; struct node *Rem; struct node *p; printf(请输入想要排队的时间n); scanf(%d,&n); if(n=8&n=MAX) printf(请输入你的学号n); scanf(%s,Infor); if(TimeQueuen.CNum)=MAX) Rem=(struct node *)malloc(sizeof(struct node); 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); else Rem=(struct node *)malloc(sizeof(struct node); strcpy(Rem-data,Infor); Rem-next=NULL; Rem-locat=0; p=TimeQueuen.last; TimeQueuen.last=Rem; p-next=Rem; TimeQueuen.CNum+; printf(成功排队n); else printf(有空余机位,无须等待n); else printf(错误.再次输入.n); void cancel() int n; int i; char Infor10; struct node *Rem; struct node *q; struct node *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(Succeed to out the queue!n); else q-next=Rem-next; free(Rem); TimeQueuen.CNum-; printf(Succeed to out the queue!n); else if(TimeQueuen.CNumMAX) TimeQueuen.middle-locat=Rem-locat; TimeQueuen.middle=TimeQueuen.middle-next; if(i=1) TimeQueuen.first=Rem-next; else q-next=Rem-next; free(Rem); TimeQueuen.CNum-; printf(成功取消预定!n); else printf(错误,请再次输入.n); void inquir_waiting() int n; struct node *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); else printf(这个时间段没有预定者n); else printf(错误。请再次输入.n); main() int i; 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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论