機房機位預約模擬C語言設計_第1頁
機房機位預約模擬C語言設計_第2頁
機房機位預約模擬C語言設計_第3頁
已閱讀5頁,還剩7頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權,請進行舉報或認領

文檔簡介

1、機房機位預約模擬題目要求20 臺機器 ,從早 8 點到晚 8 點,每兩個小時一個時段 . 需要實現(xiàn)如下功能:(1)查詢 .根據(jù)輸入時間輸出機位信息 .(2)機位預訂 .根據(jù)輸入地日期和時間段查詢是否有空機位,若有則預約 ,若無則提供最近空機時間段 .另外 ,若用戶要求在非空時間上機 ,則將用戶信息插入該時間段地等待列 表.(3)退出預訂 .根據(jù)輸入地時間撤銷該時間地預定.(4)查詢是否有等待信息 .若有則按順序顯示聯(lián)系方式 ,若無則顯示提示信息 .二 需求分析根據(jù)題目要求 , 程序需要四個結構體來完成 ,分別對應四個功能 .另外 ,這個程序還要根據(jù)時間 更新各個列表地信息 .總體設計根據(jù)上面地

2、需求分析 ,這個系統(tǒng)地設計需要四個結構體和四個列表機器信息結構體:包括 用戶信息結構體:包括 預定信息結構體:包括 等待信息結構體:包括機器編號 ,是否被占用 ,機器其他信息 用戶姓名 ,用戶其他信息機器編號 ,預訂人姓名 ,預定時間段 等待者姓名 ,等待信息添加時間再建立四個列表 分別以上述四個結構體為節(jié)點 對應地問題第一個 ,查詢機器信息列表 ,查看機器是否被占用 ,再根據(jù)預定信息列表中地內(nèi)容得到機器是 否被預定第二個 ,遍歷機器列表 ,查看每一個機器在輸入地時間是否有預定信息,如果沒有則將預定信息插入第二個列表第三個 ,根據(jù)用戶和預定時間信息刪除第三個列表中地信息第四個 ,將等待信息列表

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;(第一個功能:查詢)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)(輸出機位信息)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;(第二個功能:機位預訂)(輸入查詢時間)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;(再次輸入查詢時間)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; (第三個功能:退出預訂) 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;(第四個功能:查詢是否有等待信息) 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");四 上機操作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功能來查詢,然后輸入正確地時間先輸入錯誤時間,再改正:2.3.機位預訂功能選擇3功能來運行,截圖如下:4.退出預訂功能選擇4執(zhí)行此功能,過程如圖示預訂-! 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í)行排隊命令,圖示如下(有機位,無法退出預訂)6.選擇6查看等待信息,如圖示:7.選擇0退出主菜單存在地問題與不足及對策這套程序應用起來并不是很方便,總地說來,大致上實現(xiàn)了題目地要求 ,各個功能有相

23、應地代號來直接調用,對于初次進入主函數(shù)頁面地使用者來說,顯得不大好用不過用熟之后,都不是問題對策:對于c語言編出地程序來說,使用方法大致上都是一樣地,所以想做改進只能 從程序方面入手,盡量把指令編地簡單明了 ,方便易用本人對這一程序還是相當滿意地,想弄地更好地話可以嘗試一下用其他編輯程序來完成操作手冊點擊運行進入主菜單函數(shù),然后按數(shù)字鍵選擇所需要地服務 .1查詢我地預定狀態(tài);2查詢 空機位;3預訂機位;4退出預訂,退掉已定地機位;5排隊,即使用者若要在非空時間上機 就將該用戶信息插入到等待列表里;6查詢等待列表,看看排隊情況學習心得短短地一個星期地上機實習結束了 復習理論知識、編程、調試、改錯,直至存盤,同樣地環(huán)節(jié)、 同樣

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論