機(jī)房機(jī)位預(yù)約模擬系統(tǒng)—C語(yǔ)言課程設(shè)計(jì)_第1頁(yè)
機(jī)房機(jī)位預(yù)約模擬系統(tǒng)—C語(yǔ)言課程設(shè)計(jì)_第2頁(yè)
機(jī)房機(jī)位預(yù)約模擬系統(tǒng)—C語(yǔ)言課程設(shè)計(jì)_第3頁(yè)
機(jī)房機(jī)位預(yù)約模擬系統(tǒng)—C語(yǔ)言課程設(shè)計(jì)_第4頁(yè)
機(jī)房機(jī)位預(yù)約模擬系統(tǒng)—C語(yǔ)言課程設(shè)計(jì)_第5頁(yè)
已閱讀5頁(yè),還剩10頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、C語(yǔ)言課程設(shè)計(jì)報(bào)告機(jī)房機(jī)位預(yù)約模擬一題目要求20臺(tái)機(jī)器,從早八點(diǎn)到晚八點(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ù)題目要求,在程序中應(yīng)實(shí)現(xiàn)查詢,機(jī)位預(yù)定,插入等待列表,退出預(yù)定,查詢等待信息等功能。還應(yīng)提供鍵盤式選擇菜單實(shí)現(xiàn)功能選擇。而等待信息放在文件里,

2、所以在相關(guān)的模塊應(yīng)提供文件的輸入、輸出操作。三總體設(shè)計(jì)根據(jù)上面的需求分析,將這個(gè)系統(tǒng)的設(shè)計(jì)分為下面4個(gè)模塊:機(jī)房機(jī)位預(yù)約模擬系統(tǒng)狀態(tài)查詢模塊預(yù)訂模塊取消預(yù)訂模塊查詢等待信息模塊4詳細(xì)設(shè)計(jì) 1.預(yù)處理命令及函數(shù)聲明#include<stdio.h>#include<stdlib.h>#include<string.h>#define N 20#define T (time-8)/2int sum6=0;int computer620=1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,

3、0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,1,1,1;/*該數(shù)組表示假設(shè)某天某人查詢時(shí)機(jī)房各個(gè)時(shí)間段機(jī)位數(shù)情況*/void Menu(); void Situation();void Book();void Cancel();void SearchWaiting();void Exit();void

4、detail(int time);void printf_one(int i); struct waitlist char number3; char telephonenumber12; waitN;2主函數(shù)主函數(shù)一般設(shè)計(jì)得比較簡(jiǎn)潔,只提供輸入,處理和輸出部分的函數(shù)調(diào)用。其中各功能模塊用菜單方式選擇。其流程圖如圖所示:開始顯示一系列功能模塊根據(jù)的值調(diào)用各功能模塊函數(shù)YN輸入n的值1-5結(jié)束 2./*主函數(shù)*/void main()Menu(); /*當(dāng)前狀態(tài)函數(shù)*/void Menu() /*主界面*/int n,w;do puts("tt*COMPUTER BOOK SYSTER

5、M*n"); puts("tt*MENU*n"); puts("ttt 1.Search the current situation"); /*查詢某時(shí)間段機(jī)位狀態(tài)*/ puts("ttt 2.Book the vacant computer"); /*預(yù)定空機(jī)位*/ puts("ttt 3.Cancel booking"); /*取消預(yù)訂*/ puts("ttt 4.Search waiting"); /*查詢等待信息*/ puts("ttt 5.Exit");

6、/*退出*/ puts("tt*n"); printf("Choose your number(1-5): bb"); scanf("%d",&n); if(n<1|n>5) w=1;getchar(); else w=0;while(w=1);switch(n)case 1:Situation();break;case 2:Book();break; case 3:Cancel();break; case 4:SearchWaiting();break; case 5:Exit(0);break;3.狀態(tài)查詢函數(shù)

7、流程圖調(diào)用detail函數(shù)返回主菜單輸入1是否輸入time的值8-20開始/*查詢模塊*/*查詢當(dāng)前狀態(tài)*/void Situation()int time;printf("Input time between (8-20):");scanf("%d",&time);if(time<8|time>20)printf("tWrong time!n");printf("Please input time between (8-20):");scanf("%d",&time

8、); detail(time); /*函數(shù)調(diào)用*/getchar();Menu();4.預(yù)定模塊函數(shù)流程圖開始N執(zhí)行一個(gè)循環(huán),進(jìn)入后面的時(shí)間段SumT>0輸入時(shí)間8-20調(diào)用detail函數(shù),sumT的值改變輸出空機(jī)位數(shù),是否等待NY打開文本文件waitlist.txt,輸入預(yù)定機(jī)位號(hào)和聯(lián)系方式,追加一個(gè)結(jié)構(gòu)體成員。返回主菜單程序:/*預(yù)定模塊*/void Book()int time,i=0,x,y;FILE *fp; char c; printf("Input time you want to book between(8-20):"); scanf("

9、%d",&time); if(time<8|time>20) printf("tWrong time!n"); printf("tInput time you want to book between(8-20):"); scanf("%d",&time); detail(time); /*函數(shù)調(diào)用*/if(sumT>0) if(fp=fopen("waitlist.txt","a")=NULL) printf("nCannot open f

10、ile!n"); exit(0); printf("ntPlease Input the number you want to book and leave your telephonenumber!:n"); scanf("%s %s",waiti.number,waiti.telephonenumber);for(i=0;i<1;i+) fwrite(&waiti,sizeof(struct waitlist),1,fp); fclose(fp);/*向文本文檔添加一個(gè)結(jié)構(gòu)體單元*/printf("tInput th

11、e number you want to book again!n");scanf("%d",&x);sumT-; / *預(yù)定后該時(shí)間段空機(jī)位數(shù)減1*/computerTx=1; / *預(yù)定后該機(jī)狀態(tài)變?yōu)?*/printf("tBook succeed!n");getchar();Menu();elseprintf("There is no vacant computer at that time!n");for(i=T+1;i<6;i+) time=9+2*i;detail(time); /*函數(shù)調(diào)用*/if

12、(sumT>0)printf("tThe latest free time is %d,%dn",2*i+8,2*i+10);break;printf("tDo you want to wait?:y/n?");scanf("%s",&c);getchar();if(c='Y'|c='y') if(fp=fopen("waitlist.txt","r")=NULL) printf("nCannot open file!n"); e

13、xit(0); else printf("waitlist: number telephonenumbern"); for(i=0;!feof(fp);i+) fscanf(fp,"%s %s",&waiti.number,&waiti.telephonenumber); fclose(fp); for(i=0;i<10;i+) printf_one(i); printf("ntPlease Input the number you want to book and leave your telephonenumber!:

14、n"); if(fp=fopen("waitlist.txt","a")=NULL) printf("nCannot open file!n"); exit(0); scanf("%s %s",waiti.number,waiti.telephonenumber); for(i=0;i<1;i+) fwrite(&waiti,sizeof(struct waitlist),1,fp); fclose(fp); /*若等待,就用文件的方式列出當(dāng)時(shí)的等待列表并提示輸入你的等待序號(hào)和聯(lián)系方式*/p

15、rintf("Input the number of the computer again!n");scanf("%d",&y);sumT-; computerTy=1; printf("tOk,please wait our phone!n"); Menu(); else Menu();5,取消預(yù)訂模塊函數(shù)流程圖調(diào)用detail函數(shù)輸入機(jī)位號(hào)YN輸入時(shí)間8-20開始該時(shí)間段空電腦數(shù)加1,所取消電腦號(hào)狀態(tài)變?yōu)?主菜單/*取消預(yù)訂模塊*/void Cancel()int time,number;printf("Inpu

16、t time you have booked between(8-20):");scanf("%d",&time); if(time<8|time>20) printf("tWrong time!n"); printf("tInput time you have booked between(8-20):"); scanf("%d",&time); elseprintf("tInput number you have booked :");scanf(&qu

17、ot;%d",&number);detail(time); sumT+; / *預(yù)定后該時(shí)間段空機(jī)位數(shù)加1*/computerTnumber=0; / *預(yù)定后該機(jī)狀態(tài)變?yōu)?*/printf("tCancel succeed!n");getchar();Menu();6查詢等待信息模塊流程圖開始輸入時(shí)間8-20打開文本文件,將文本文件轉(zhuǎn)化為二進(jìn)制文件輸出到屏幕上,顯示等待信息YN返回主菜單/*查詢等待信息模塊*/void SearchWaiting()int time,i; FILE *fp;printf("tInput time you wan

18、t to search between(8-20):");scanf("%d",&time);if(time<8|time>20) printf("tWrong time!n"); printf("tInput time you want to search between(8-20):"); scanf("%d",&time);else; if(fp=fopen("waitlist.txt","r")=NULL) printf("nCannot open file!n"); exit(0); else printf("waitlist: number telephonenumbern"); for(i=0;

溫馨提示

  • 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ù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 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ì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論