版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、機(jī)房機(jī)位預(yù)約模擬題目要求20 臺(tái)機(jī)器 ,從早 8 點(diǎn)到晚 8 點(diǎn),每?jī)蓚€(gè)小時(shí)一個(gè)時(shí)段 . 需要實(shí)現(xiàn)如下功能:(1)查詢 .根據(jù)輸入時(shí)間輸出機(jī)位信息 .(2)機(jī)位預(yù)訂 .根據(jù)輸入地日期和時(shí)間段查詢是否有空機(jī)位,若有則預(yù)約 ,若無(wú)則提供最近空機(jī)時(shí)間段 .另外 ,若用戶要求在非空時(shí)間上機(jī) ,則將用戶信息插入該時(shí)間段地等待列 表.(3)退出預(yù)訂 .根據(jù)輸入地時(shí)間撤銷該時(shí)間地預(yù)定.(4)查詢是否有等待信息 .若有則按順序顯示聯(lián)系方式 ,若無(wú)則顯示提示信息 .二 需求分析根據(jù)題目要求 , 程序需要四個(gè)結(jié)構(gòu)體來(lái)完成 ,分別對(duì)應(yīng)四個(gè)功能 .另外 ,這個(gè)程序還要根據(jù)時(shí)間 更新各個(gè)列表地信息 .總體設(shè)計(jì)根據(jù)上面地
2、需求分析 ,這個(gè)系統(tǒng)地設(shè)計(jì)需要四個(gè)結(jié)構(gòu)體和四個(gè)列表機(jī)器信息結(jié)構(gòu)體:包括 用戶信息結(jié)構(gòu)體:包括 預(yù)定信息結(jié)構(gòu)體:包括 等待信息結(jié)構(gòu)體:包括機(jī)器編號(hào) ,是否被占用 ,機(jī)器其他信息 用戶姓名 ,用戶其他信息機(jī)器編號(hào) ,預(yù)訂人姓名 ,預(yù)定時(shí)間段 等待者姓名 ,等待信息添加時(shí)間再建立四個(gè)列表 分別以上述四個(gè)結(jié)構(gòu)體為節(jié)點(diǎn) 對(duì)應(yīng)地問(wèn)題第一個(gè) ,查詢機(jī)器信息列表 ,查看機(jī)器是否被占用 ,再根據(jù)預(yù)定信息列表中地內(nèi)容得到機(jī)器是 否被預(yù)定第二個(gè) ,遍歷機(jī)器列表 ,查看每一個(gè)機(jī)器在輸入地時(shí)間是否有預(yù)定信息,如果沒(méi)有則將預(yù)定信息插入第二個(gè)列表第三個(gè) ,根據(jù)用戶和預(yù)定時(shí)間信息刪除第三個(gè)列表中地信息第四個(gè) ,將等待信息列表
3、地內(nèi)容顯示程序內(nèi)容如下:#include<stdio.h>#include<stdlib.h>#include<string.h>#define LENGTH 6#define MAX 20#define S(r) (r-8)/2#define NULL 0struct nodeint locat;char data10;struct node *next;struct node *head;struct cellint CNum;struct node *first;struct node *middle;struct node *last;TimeQue
4、ueLENGTH;void Inquir()int n;char Infor10;struct node *Rem;(第一個(gè)功能:查詢)printf("Please input the time you want to search!(24 hours 820 o'clock,include 8o'clock)n"); scanf("%d",&n) ;if(n>=8&&n<20)n=S(n);printf("Please input your No.!n");scanf("
5、%s",Infor);Rem=TimeQueuen.first;for(;Rem->next!=NULL;Rem=Rem->next) if(strcmp(Rem->data,Infor)=0)break;if(Rem->locat!=0)(輸出機(jī)位信息)printf("The computer number is %dn",Rem->locat);else printf("Sorry,you are still in the queue or you haven't booked!");else prin
6、tf("Error!Please input again.n");void inquir()int n;printf("Please input the time you want to search!(24 hours 820o'clock,include 8 o'clock)n"); scanf("%d",&n); if(n>=8&&n<20) n=S(n);if(TimeQueuen.CNum<MAX)printf("There are %d empty com
7、puter!n",MAX-TimeQueuen.CNum); else printf("Sorry,there is no empty computer!n");else printf("Error!Please input again.n");void booking()int n;char Infor10;struct node *Rem;struct node *p;(第二個(gè)功能:機(jī)位預(yù)訂)(輸入查詢時(shí)間)printf("Please input the time you want to book!n"); scanf
8、("%d",&n);if(n>=8&&n<20) n=S(n);if(TimeQueuen.CNum<MAX)printf("Please input your No.!n");scanf("%s",Infor);if(TimeQueuen.first=NULL)Rem=(struct node *)malloc(sizeof(struct node);Rem->locat=1; strcpy(Rem->data,Infor); Rem->next=NULL;TimeQueu
9、en.first=Rem;TimeQueuen.last=Rem;TimeQueuen.CNum+;printf("Succeed to book!n");elseRem=(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->nex
10、t=Rem;TimeQueuen.CNum+;printf("Succeed to book!n");else printf("There in no empty computer!");else printf("Error!Please input again.n");void waiting()int n;char Infor10;struct node *Rem;struct node *p;(再次輸入查詢時(shí)間)printf("Please input the time you want to queue!n"
11、;); scanf("%d",&n);if(n>=8&&n<20)n=S(n);if(TimeQueuen.CNum>=MAX)printf("Please input your No.!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
12、=TimeQueuen.last;TimeQueuen.last=Rem;p->next=Rem;TimeQueuen.middle=Rem;TimeQueuen.CNum+;printf("Succeed to in the queue!n");elseRem=(struct node *)malloc(sizeof(struct node);strcpy(Rem->data,Infor);Rem->next=NULL;Rem->locat=0; p=TimeQueuen.last;TimeQueuen.last=Rem; p->next=R
13、em;TimeQueuen.CNum+;printf("Succeed to in the queue!n");else printf("There have empty computer!No waiting!n"); else printf("Error!Please input again.n");void cancel()int n;int i;char Infor10;struct node *Rem;struct node *q;struct node *p; (第三個(gè)功能:退出預(yù)訂) printf("Pleas
14、e input the time you have booked!n"); scanf("%d",&n);if(n>=8&&n<20)printf("Please input your No.!n"); scanf("%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(Re
15、m->next=NULL) q->next=NULL;TimeQueuen.last=q;free(Rem);TimeQueuen.CNum-; printf("Succeed to out the queue!n"); elseq->next=Rem->next;free(Rem);TimeQueuen.CNum-;printf("Succeed to out the queue!n");elseif(TimeQueuen.CNum>MAX)TimeQueuen.middle->locat=Rem->locat
16、;TimeQueuen.middle=TimeQueuen.middle->next;if(i=1) TimeQueuen.first=Rem->next;else q->next=Rem->next;free(Rem);TimeQueuen.CNum-;printf("Succeed to exit booking!n");else printf("Error!Please input again.n");void inquir_waiting()int n;struct node *q;(第四個(gè)功能:查詢是否有等待信息) pr
17、intf("Please input the time you want to search if there are waiter!n"); scanf("%d",&n);if(n>=8&&n<20)n=S(n);if(TimeQueuen.CNum>MAX)printf("The waiting queue are:n");q=TimeQueuen.middle;for(;q->next!=NULL;q=q->next) printf("%sn",q->
18、;data); printf("%sn",TimeQueuen.last->data);else printf("There are no waiter during this period !n");else printf("Eroor!Please input again.n");main()int i;for(i=0;i<LENGTH;i+)TimeQueuei.CNum=0;TimeQueuei.first=NULL;TimeQueuei.middle=NULL;TimeQueuei.last=NULL;while
19、(1)printf("Please input the number!:n");printf("1. search my booking state 2.search empty computer 3.booking 4. cancel booking 5.queue6.search wainting 0.exitn");scanf("%d",&i);switch(i)case 1:Inquir();break;case 2:inquir();break;case 3:booking();break;case 4:cancel
20、();break;case 5:waiting();break;case 6:inquir_waiting();break;case 0:exit(0);default:printf("errorn");四 上機(jī)操作1 主菜單函數(shù)F" "F:054073-22王超宇Debug王趨宇.exe"-! x|Please input the number*:1. search my booking state 2.search empty computer 3.booking 4. cancel booking.queue 6.search waint
21、ing 0.exitI微軟拼音半:Bl查詢功能選擇2功能來(lái)查詢,然后輸入正確地時(shí)間先輸入錯(cuò)誤時(shí)間,再改正:2.3.機(jī)位預(yù)訂功能選擇3功能來(lái)運(yùn)行,截圖如下:4.退出預(yù)訂功能選擇4執(zhí)行此功能,過(guò)程如圖示預(yù)訂-! x|阿下汽”軸初-疋王趨宇Debug王超宇.亡臨"Please input the nLimber?:1. search my booking state 2.search empty computep 3.booking 4. cancel booking .queue 6.search wainting B.exitbPlease input the time you wan
22、t to book*15Please input your No.*12Succeed to book?Please input the number!:1. search my booking state 2.search empty computer 3.booking 4. cancel booking .queue 6.search uainting 0-exitI微軟拼音半:退訂5.選擇5執(zhí)行排隊(duì)命令,圖示如下(有機(jī)位,無(wú)法退出預(yù)訂)6.選擇6查看等待信息,如圖示:7.選擇0退出主菜單存在地問(wèn)題與不足及對(duì)策這套程序應(yīng)用起來(lái)并不是很方便,總地說(shuō)來(lái),大致上實(shí)現(xiàn)了題目地要求 ,各個(gè)功能有相
23、應(yīng)地代號(hào)來(lái)直接調(diào)用,對(duì)于初次進(jìn)入主函數(shù)頁(yè)面地使用者來(lái)說(shuō),顯得不大好用不過(guò)用熟之后,都不是問(wèn)題對(duì)策:對(duì)于c語(yǔ)言編出地程序來(lái)說(shuō),使用方法大致上都是一樣地,所以想做改進(jìn)只能 從程序方面入手,盡量把指令編地簡(jiǎn)單明了 ,方便易用本人對(duì)這一程序還是相當(dāng)滿意地,想弄地更好地話可以嘗試一下用其他編輯程序來(lái)完成操作手冊(cè)點(diǎn)擊運(yùn)行進(jìn)入主菜單函數(shù),然后按數(shù)字鍵選擇所需要地服務(wù) .1查詢我地預(yù)定狀態(tài);2查詢 空機(jī)位;3預(yù)訂機(jī)位;4退出預(yù)訂,退掉已定地機(jī)位;5排隊(duì),即使用者若要在非空時(shí)間上機(jī) 就將該用戶信息插入到等待列表里;6查詢等待列表,看看排隊(duì)情況學(xué)習(xí)心得短短地一個(gè)星期地上機(jī)實(shí)習(xí)結(jié)束了 復(fù)習(xí)理論知識(shí)、編程、調(diào)試、改錯(cuò),直至存盤,同樣地環(huán)節(jié)、 同樣
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 二零二五年度模特時(shí)尚品牌代言聘用合同-@-15
- 2025年度事業(yè)單位網(wǎng)絡(luò)安全管理員勞動(dòng)合同范本3篇
- 二零二五年度內(nèi)墻涂料研發(fā)生產(chǎn)與品牌營(yíng)銷承包合同
- 2025年度智能晾曬系統(tǒng)配套個(gè)人木工裝修合同3篇
- 2025年度個(gè)人閑置物品轉(zhuǎn)讓合同范本3篇
- 2025年度個(gè)人投資理財(cái)咨詢服務(wù)合同范本8篇
- 2025年度個(gè)人住房貸款質(zhì)押合同標(biāo)準(zhǔn)文本及貸款逾期處理規(guī)定3篇
- 2025年度個(gè)人房地產(chǎn)抵押借款合同電子簽名版
- 二零二五年度農(nóng)家樂(lè)民宿設(shè)施使用權(quán)轉(zhuǎn)讓合同4篇
- 2025年度個(gè)人股權(quán)收購(gòu)與轉(zhuǎn)讓合同(資產(chǎn)重組版)3篇
- 射頻在疼痛治療中的應(yīng)用
- 和平精英電競(jìng)賽事
- 四年級(jí)數(shù)學(xué)豎式計(jì)算100道文檔
- “新零售”模式下生鮮電商的營(yíng)銷策略研究-以盒馬鮮生為例
- 項(xiàng)痹病辨證施護(hù)
- 職業(yè)安全健康工作總結(jié)(2篇)
- 懷化市數(shù)字經(jīng)濟(jì)產(chǎn)業(yè)發(fā)展概況及未來(lái)投資可行性研究報(bào)告
- 07FD02 防空地下室電氣設(shè)備安裝
- 教師高中化學(xué)大單元教學(xué)培訓(xùn)心得體會(huì)
- 彈簧分離問(wèn)題經(jīng)典題目
- 部編版高中歷史中外歷史綱要(下)世界史導(dǎo)言課課件
評(píng)論
0/150
提交評(píng)論