




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
.程序設(shè)計報告設(shè)計者:肖昊班級序號:055071-27學(xué)號:20071003651指導(dǎo)老師:劉文中.語言程序設(shè)計程實踐是學(xué)習(xí)C語言程序設(shè)計的一重要環(huán)節(jié),為提高學(xué)生程序設(shè)計能力,精品文檔放心下載過課堂和上機(jī)實踐練習(xí)使學(xué)生的程序設(shè)計能力上一臺階。通過前四單元溫顧而知新、庖丁解牛、舉一反三、熟能生巧等過程的練習(xí)設(shè)計下面一個完整的程序精品文檔放心下載題目要求設(shè)計“機(jī)房機(jī)位預(yù)約模擬系統(tǒng) ”要求:20臺機(jī)器,從早8點到晚8點,每兩個小時一個時間段。感謝閱讀需要實現(xiàn)功能:1,查詢,根據(jù)輸入時間,輸出機(jī)位信息。2,即為預(yù)定,根據(jù)輸入的日期和時間段查詢是否有空機(jī)位,若有則預(yù)約,若無感謝閱讀則提供最近空機(jī)時間段。另:若用戶要求在非空時間上機(jī),則將用戶信息插入該感謝閱讀.時間段的等待列表.3,退出預(yù)定,根據(jù)輸入的時間,撤銷該時間的預(yù)定。4,查詢是否有等待的信息,若有則按順序顯示聯(lián)系方式,若無則顯示提示信息。謝謝閱讀需求分析據(jù)題目要求在程序中需實現(xiàn)查詢,預(yù)定,排隊等功能的操作,所以需要建立相應(yīng)的模塊來實現(xiàn);另外還需提供鍵盤式選擇菜單實現(xiàn)功謝謝閱讀能,在運行時達(dá)到所要目的。3總體設(shè)計整個系統(tǒng)可分為3個模塊查詢模塊預(yù)定模塊取消模塊精品文檔放心下載機(jī)房機(jī)位預(yù)約模擬系統(tǒng)查詢模塊 預(yù)定模塊 取消模塊詳細(xì)設(shè)計主函數(shù)比較簡潔,只提供輸入、功能處理和輸出部分的函數(shù)調(diào)謝謝閱讀用。.開始顯示一系列功能選擇輸入n,判斷m是否是0到6?
N根據(jù)n值調(diào)用各功能模塊函數(shù)結(jié)束main(){inti;for(i=0;i<LENGTH;i++){TimeQueue[i].CNum=0;TimeQueue[i].first=NULL;TimeQueue[i].middle=NULL;TimeQueue[i].last=NULL;}while(1){printf("請輸入序號!:\n");printf("1.查詢預(yù)定的機(jī)位2.查詢空機(jī)位3.預(yù)定4.取消預(yù)定5.等待列表6.查詢等待者謝謝閱讀列表0.退出\n");.scanf("%d",&i);switch(i){case1:Inquir();break;case2:inquir();break;case3:booking();break;case4:cancel();break;case5:waiting();break;case6:inquir_waiting();break;謝謝閱讀case0:exit(0);default:printf("error\n");謝謝閱讀}}}.開始輸入查詢序號或查詢時間判斷是否預(yù)定,是否N有空余機(jī)位?顯示數(shù)據(jù)結(jié)束voidInquir(){intn;charInfor[10];structnode*Rem;printf("輸入查詢時間(24hours8~20o'clock,include8o'clock)\n");感謝閱讀scanf("%d",&n);if(n>=8&&n<20){n=S(n);printf("請輸入學(xué)號\n");scanf("%s",Infor);Rem=TimeQueue[n].first;for(;Rem->next!=NULL;Rem=Rem->next)感謝閱讀.if(strcmp(Rem->data,Infor)==0)break;精品文檔放心下載if(Rem->locat!=0)printf("Thecomputernumberis%d\n",Rem->locat);謝謝閱讀elseprintf("對不起.你依舊在等待列表中或者沒有預(yù)定");精品文檔放心下載}elseprintf("錯誤,請再次輸入.\n");謝謝閱讀}voidinquir(){intn;printf("輸入想要查詢的時間(24hours8~20o'clock,include8o'clock)\n");謝謝閱讀scanf("%d",&n);if(n>=8&&n<20){n=S(n);if(TimeQueue[n].CNum<MAX)printf("Thereare%demptycomputer!\n",MAX-TimeQueue[n].CNum);精品文檔放心下載elseprintf("對不起.沒有空余機(jī)位\n");感謝閱讀}elseprintf("錯誤,再次輸入.\n");感謝閱讀}預(yù)定模塊.開始輸入預(yù)定時間判斷時間屬于 8~20o'clock與空機(jī)位
選擇排隊N輸入學(xué)號預(yù)定成功,排隊成功voidbooking() 結(jié)束{intn;charInfor[10];structnode*Rem;structnode*p;printf("輸入想要預(yù)定的時間\n");scanf("%d",&n);if(n>=8&&n<20){n=S(n);if(TimeQueue[n].CNum<MAX){謝謝閱讀printf("請輸入你的學(xué)號\n");scanf("%s",Infor);.if(TimeQueue[n].first==NULL){感謝閱讀Rem=(structnode*)malloc(sizeof(structnode));感謝閱讀Rem->locat=1;strcpy(Rem->data,Infor);Rem->next=NULL;TimeQueue[n].first=Rem;TimeQueue[n].last=Rem;TimeQueue[n].CNum++;printf("成功預(yù)定\n");}else{Rem=(structnode*)malloc(sizeof(structnode));謝謝閱讀strcpy(Rem->data,Infor);Rem->next=NULL;p=TimeQueue[n].last;Rem->locat=TimeQueue[n].CNum+1;感謝閱讀printf("%d",Rem->locat);TimeQueue[n].last=Rem;p->next=Rem;TimeQueue[n].CNum++;printf("成功預(yù)定\n");}.}elseprintf("沒有空余機(jī)位!");}elseprintf("錯誤.請再次輸入.\n");精品文檔放心下載}voidwaiting(){intn;charInfor[10];structnode*Rem;structnode*p;printf("請輸入想要排隊的時間\n");scanf("%d",&n);if(n>=8&&n<20){n=S(n);if(TimeQueue[n].CNum>=MAX){感謝閱讀printf("請輸入你的學(xué)號\n");scanf("%s",Infor);if((TimeQueue[n].CNum)==MAX){精品文檔放心下載Rem=(structnode*)malloc(sizeof(structnode));精品文檔放心下載.strcpy(Rem->data,Infor);Rem->next=NULL;Rem->locat=0;p=TimeQueue[n].last;TimeQueue[n].last=Rem;p->next=Rem;TimeQueue[n].middle=Rem;TimeQueue[n].CNum++;printf("成功排隊\n");}else{Rem=(structnode*)malloc(sizeof(structnode));謝謝閱讀strcpy(Rem->data,Infor);Rem->next=NULL;Rem->locat=0;p=TimeQueue[n].last;TimeQueue[n].last=Rem;p->next=Rem;TimeQueue[n].CNum++;printf("成功排隊\n");}}.elseprintf("有空余機(jī)位,無須等待\n");謝謝閱讀}elseprintf("錯誤.再次輸入.\n");謝謝閱讀}取 消 模 塊開始輸入預(yù)定時間N判斷是否預(yù)定與排隊成功取消預(yù)定結(jié)束voidcancel(){intn;inti;charInfor[10];structnode*Rem;.structnode*q;structnode*p;printf("請輸入預(yù)定的時間\n");scanf("%d",&n);if(n>=8&&n<20){printf("PleaseinputyourNo.!\n");感謝閱讀scanf("%s",Infor);n=S(n);Rem=TimeQueue[n].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;TimeQueue[n].last=q;free(Rem);TimeQueue[n].CNum--;printf("Succeedtooutthequeue!\n");感謝閱讀}else{q->next=Rem->next;.free(Rem);TimeQueue[n].CNum--;printf("Succeedtooutthequeue!\n");感謝閱讀}}else{if(TimeQueue[n].CNum>MAX){精品文檔放心下載TimeQueue[n].middle->locat=Rem->locat;謝謝閱讀TimeQueue[n].middle=TimeQueue[n].middle->next;精品文檔放心下載}if(i==1)TimeQueue[n].first=Rem->next;感謝閱讀elseq->next=Rem->next;free(Rem);TimeQueue[n].CNum--;printf("成功取消預(yù)定!\n");附錄源代碼:#include<stdio.h>#include<stdlib.h>#include<string.h>#defineLENGTH6.#defineMAX20#defineS(r)(r-8)/2#defineNULL0structnode{intlocat;chardata[10];structnode*next;};structnode*head;structcell{intCNum;structnode*first;structnode*middle;structnode*last;}TimeQueue[LENGTH];voidInquir(){intn;.charInfor[10];structnode*Rem;printf("輸入查詢時間(24hours8~20o'clock,include8o'clock)\n");謝謝閱讀scanf("%d",&n);if(n>=8&&n<20){n=S(n);printf("請輸入學(xué)號\n");scanf("%s",Infor);Rem=TimeQueue[n].first;for(;Rem->next!=NULL;Rem=Rem->next)精品文檔放心下載if(strcmp(Rem->data,Infor)==0)break;感謝閱讀if(Rem->locat!=0)printf("Thecomputernumberis%d\n",Rem->locat);感謝閱讀elseprintf("對不起.你依舊在等待列表中或者沒有預(yù)定");謝謝閱讀}elseprintf("錯誤,請再次輸入.\n");謝謝閱讀}voidinquir(){intn;printf("輸入想要查詢的時間(24hours8~20o'clock,include8o'clock)\n");感謝閱讀.scanf("%d",&n);if(n>=8&&n<20){n=S(n);if(TimeQueue[n].CNum<MAX)printf("Thereare%demptycomputer!\n",MAX-TimeQueue[n].CNum);精品文檔放心下載elseprintf("對不起.沒有空余機(jī)位\n");精品文檔放心下載}elseprintf("錯誤,再次輸入.\n");感謝閱讀}voidbooking(){intn;charInfor[10];structnode*Rem;structnode*p;printf("輸入想要預(yù)定的時間\n");scanf("%d",&n);if(n>=8&&n<20){n=S(n);if(TimeQueue[n].CNum<MAX){精品文檔放心下載.printf("請輸入你的學(xué)號\n");scanf("%s",Infor);if(TimeQueue[n].first==NULL){謝謝閱讀Rem=(structnode*)malloc(sizeof(structnode));感謝閱讀Rem->locat=1;strcpy(Rem->data,Infor);Rem->next=NULL;TimeQueue[n].first=Rem;TimeQueue[n].last=Rem;TimeQueue[n].CNum++;printf("成功預(yù)定\n");}else{Rem=(structnode*)malloc(sizeof(structnode));精品文檔放心下載strcpy(Rem->data,Infor);Rem->next=NULL;p=TimeQueue[n].last;Rem->locat=TimeQueue[n].CNum+1;精品文檔放心下載printf("%d",Rem->locat);TimeQueue[n].last=Rem;p->next=Rem;.TimeQueue[n].CNum++;printf("成功預(yù)定\n");}}elseprintf("沒有空余機(jī)位!");}elseprintf("錯誤.請再次輸入.\n");謝謝閱讀}voidwaiting(){intn;charInfor[10];structnode*Rem;structnode*p;printf("請輸入想要排隊的時間\n");scanf("%d",&n);if(n>=8&&n<20){n=S(n);if(TimeQueue[n].CNum>=MAX){謝謝閱讀printf("請輸入你的學(xué)號\n");scanf("%s",Infor);.if((TimeQueue[n].CNum)==MAX){謝謝閱讀Rem=(structnode*)malloc(sizeof(structnode));謝謝閱讀strcpy(Rem->data,Infor);Rem->next=NULL;Rem->locat=0;p=TimeQueue[n].last;TimeQueue[n].last=Rem;p->next=Rem;TimeQueue[n].middle=Rem;TimeQueue[n].CNum++;printf("成功排隊\n");}else{Rem=(structnode*)malloc(sizeof(structnode));謝謝閱讀strcpy(Rem->data,Infor);Rem->next=NULL;Rem->locat=0;p=TimeQueue[n].last;TimeQueue[n].last=Rem;p->next=Rem;TimeQueue[n].CNum++;.printf("成功排隊\n");}}elseprintf("有空余機(jī)位,無須等待\n");感謝閱讀}elseprintf("錯誤.再次輸入.\n");謝謝閱讀}voidcancel(){intn;inti;charInfor[10];structnode*Rem;structnode*q;structnode*p;printf("請輸入預(yù)定的時間\n");scanf("%d",&n);if(n>=8&&n<20){printf("PleaseinputyourNo.!\n");感謝閱讀scanf("%s",Infor);.n=S(n);Rem=TimeQueue[n].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;TimeQueue[n].last=q;free(Rem);TimeQueue[n].CNum--;printf("Succeedtooutthequeue!\n");精品文檔放心下載}else{q->next=Rem->next;free(Rem);TimeQueue[n].CNum--;printf("Succeedtooutthequeue!\n");感謝閱讀}}else{if(TimeQueue[n].CNum>MAX){感謝閱讀.TimeQueue[n].middle->locat=Rem->locat;感謝閱讀TimeQueue[n].middle=TimeQueue[n].middle->next;謝謝閱讀}if(i==1)TimeQueue[n].first=Rem->next;精品文檔放心下載elseq->next=Rem->next;free(Rem);TimeQueue[n].CNum--;printf("成功取消預(yù)定!\n");}}elseprintf("錯誤,請再次輸入.\n")
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- YY/T 1946-2024腫瘤組織基因突變檢測試劑盒(高通量測序法)
- 農(nóng)副產(chǎn)品購銷示范合同
- 簽訂的門面租賃合同條款解析
- 建筑項目施工合同管理人員聘用合同
- 炒股合作經(jīng)典合同案例
- 車輛采購合同細(xì)則
- 國際物流服務(wù)合同專業(yè)版詳解
- 農(nóng)村土地流轉(zhuǎn)授權(quán)合同書
- 城市房屋拆遷補(bǔ)償安置標(biāo)準(zhǔn)合同樣本
- 鋼材買賣合同(示范文本GF-0155)
- 骶髂關(guān)節(jié)損傷郭倩課件
- 內(nèi)科學(xué)疾病概要-支氣管擴(kuò)張課件
- 2025陜西渭南光明電力集團(tuán)限公司招聘39人易考易錯模擬試題(共500題)試卷后附參考答案
- 預(yù)防感冒和流感的方法
- 2024年黑龍江職業(yè)學(xué)院高職單招語文歷年參考題庫含答案解析
- 2024年南京旅游職業(yè)學(xué)院高職單招語文歷年參考題庫含答案解析
- 股指期貨基礎(chǔ)知識介紹培訓(xùn)課件
- 2024年北京東城社區(qū)工作者招聘筆試真題
- xx學(xué)校培訓(xùn)部工作職責(zé)
- T-GXAR 005-2024 制冷機(jī)房運行維護(hù)規(guī)程
- 開工第一課安全培訓(xùn)總結(jié)精彩
評論
0/150
提交評論