




版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、客房管理系統(tǒng)1. 題目與要求:客房管理系統(tǒng)系統(tǒng)包括新用戶(hù)登記功能,統(tǒng)計(jì)功能,查詢(xún)功能,修改功能。1.1問(wèn)題提出與要求:建立如下結(jié)構(gòu)體:Struct ClientChar Name20;int Sex;int Age;char ID-card ; /*居民身份證*/ int year ;int month;int date; ;Struct HotelInt Room-ID; /*房間號(hào)*/Int Tel;int Price;bool sign; /*標(biāo)記房間是否為空房間*/Struct Client Client-list; /*實(shí)現(xiàn)兩結(jié)構(gòu)體的嵌套*/ RoomNUM 需求分析根據(jù)題目要求,客
2、房信息要用文件存儲(chǔ),提供文件的輸入輸出操作;在程序中需要對(duì)客房具有登記,統(tǒng)計(jì),查詢(xún)和修改的功能;另外還要用鍵盤(pán)式菜單實(shí)現(xiàn)功能選擇.2.功能實(shí)現(xiàn)設(shè)計(jì):2.1總體設(shè)計(jì):下面來(lái)分析一下整個(gè)系統(tǒng),根據(jù)上面的要求分析,可將這個(gè)系統(tǒng)設(shè)計(jì)為五大模塊(見(jiàn)下圖):注冊(cè)模塊,統(tǒng)計(jì)模塊,查詢(xún)模塊,修改模塊,退出模塊。其主要功能為:注冊(cè),統(tǒng)計(jì),查詢(xún),修改功能??头抗芾硐到y(tǒng) 系統(tǒng)系統(tǒng) 注冊(cè)統(tǒng)計(jì) 查詢(xún)修改退出2.2詳細(xì)設(shè)計(jì): 主函數(shù)主函數(shù)一般設(shè)計(jì)得比較簡(jiǎn)潔,提供輸入,功能處理和輸出部分的函數(shù)調(diào)用。其中各功能模塊用菜單方式選擇。流程圖顯示一系列功能選項(xiàng)輸入n,判斷n是否是?根據(jù)n的值調(diào)用各功能模塊函數(shù)結(jié)束開(kāi)始NY程序voi
3、d main() /*主函數(shù)*/ int n,w=1; /*變量n保存選擇菜單數(shù)字,w判斷輸入的數(shù)字是否在功能菜單對(duì)應(yīng)的數(shù)字范圍之內(nèi)*/ struct Hotel *info; while(w)puts("tt C語(yǔ)言課程設(shè)計(jì) 客房管理系統(tǒng) n");puts("tt 072084班 丁超 學(xué)號(hào):20081003552n");puts("tt*n");puts("tt*MENU*n");puts("tt*1 registration*n"); /*注冊(cè)*/ puts("tt*2stati
4、stic*n"); /*統(tǒng)計(jì)*/ puts("tt*3search*n"); /*查詢(xún)*/ puts("tt*4modify *n"); /*修改*/ puts("tt*5exit*n"); /*退出*/ puts("tt*n"); puts("tt*n"); printf("Choice your number(1-5):bb"); scanf("%d",&n); if(n<1|n>5) /*對(duì)選擇的數(shù)字作判斷*/ w=1;
5、 getchar(); switch(n) case 1:regi();break; /*注冊(cè)模塊*/ case 2:stat();break; /*統(tǒng)計(jì)模塊*/ case 3:search();break; /*查詢(xún)模塊*/ case 4:modify();break; /*修改模塊*/ case5:tuichu();break; /*退出模塊 */ default: break; getchar(); 功能模塊設(shè)計(jì).1 注冊(cè)模塊 單獨(dú)看各數(shù)據(jù)信息,身份證號(hào)碼均是字符型,可采用字符型數(shù)組;用戶(hù)在填完個(gè)人信息,即可進(jìn)行房間預(yù)定。流程圖用戶(hù)輸入信息i!=o嗎? 保存調(diào)用函數(shù) 返回開(kāi)始NY返回主菜
6、單程序regi() /*注冊(cè)模塊*/ int i,n; struct Hotel *info; char s10; char a10="have" printf(" people number:n"); scanf("%d",&n); for(i=0;i<n;i+) info=(struct Hotel*)malloc(sizeof(RoomNUM); if(info=0) printf(" memroy used overn"); inputs(" t Room_ID:n",in
7、fo->Room_ID,10); if(!(char*)(info->Room_ID)0) break; inputs(" t have people put have nopeople put nulln",info->person,10); if(strcmp(a,info->person) inputs("t name:n",info->Client_list.Name,20); inputs("t sex:n",info->Client_list.Sex,10); inputs("
8、t age:n",info->Client_list.Age,10); inputs("t Id_card:n",info->Client_list.ID_card,20); inputs("t year:n",info->Client_list.year,10); inputs("t month:n",info->Client_list.month,10); inputs("t date:n",info->Client_list.date,10); inputs("
9、;t Tel:n",info->Tel,10); inputs("t Price:n",info->Price,10); printf("t registration donen"); start=dls_store(info,start); inputs(char *prompt, char *s,int count) char p255; do printf("%s",prompt); scanf("%s",p); if(strlen(p)>count) printf("
10、too long!n "); while(strlen(p)>count); strcpy(s,p); struct Hotel *dls_store(struct Hotel *i,struct Hotel *top) static struct Hotel *last=0; struct Hotel *old,*p; if(last=NULL) i->next=NULL; i->prior=NULL; last=i; return i; p=top; old=NULL; while(p) if(strcmp(p->Room_ID,i->Room_ID
11、)<0) old=p; p=p->next; else if(p->prior) p->prior->next=i; i->next=p; p->prior=i; return top; i->next=p; i->prior=0; p->prior=i; return i; old->next=i; i->next=0; i->prior=old; last=i; return start; 統(tǒng)計(jì)模塊有兩種數(shù)據(jù)進(jìn)行統(tǒng)計(jì),被占用的房間和未被占用的房間。流程圖統(tǒng)計(jì)對(duì)象 統(tǒng)計(jì)合適房間統(tǒng)計(jì)被占用房間統(tǒng)計(jì)未被
12、占用房間程序stat() /*統(tǒng)計(jì)模塊*/ struct Hotel *info; char a10="null" char b10="have" int c,count=0; printf("t statistic the used Room_ID put 1, the unused Room_ID put 2 n"); scanf("%d",&c); if(c=1) info=start; while(info) if(!strcmp(a,info->person) printf("Ro
13、om_ID %s n",info->Room_ID); count+; info=info->next; printf("t used rooms are%sn",count); /*統(tǒng)計(jì)被占用的房間*/ if(c=2) info=start; while(info) if(!strcmp(b,info->person) printf("t Room_ID %s n",info->Room_ID); count+; info=info->next; printf("t unused rooms are%s
14、n",count); /*統(tǒng)計(jì)未被占用的房間*/ display(struct Hotel *info) printf("tt name:%sn",info->Client_list.Name); printf("tt sex:%sn",info->Client_list.Sex); printf("tt age:%sn",info->Client_list.Age); printf("tt Id_card:%sn",info->Client_list.ID_card); prin
15、tf("tt year:%sn",info->Client_list.year); printf("tt month:%sn",info->Client_list.month); printf("tt date:%sn",info->Client_list.date); printf("tt Tel:%sn",info->Tel); printf("tt Price:%sn",info->Price); printf("n");
16、查詢(xún)模塊查詢(xún)通??杉?xì)分為分類(lèi)查找,此題中分為合適查找,被占用查找,未被占用查找。再與統(tǒng)計(jì)信息進(jìn)行對(duì)應(yīng),顯示對(duì)應(yīng)數(shù)據(jù),則用戶(hù)即可知道合適房間。程序 search() /*查詢(xún)模塊*/ int b; printf(" t search the fixed room put 1n"); printf(" t search the used room put 2n"); printf(" t search the unused room put 3n"); printf(" t back to the main menu put 4
17、n"); do scanf("%d",&b); switch(b) case 1: search1();break; case 2: search2();break; case 3: search3();break; case 4: return; while(b<1|b>4); struct Hotel *find(char *Room_ID) struct Hotel *info; info=start; while(info) if(!strcmp(Room_ID,info->Room_ID) return info; info=i
18、nfo->next; printf(" t can't findn"); return (NULL); search1() char Room_ID10; struct Hotel *info; printf(" t put the Room_ID n"); scanf("%s",Room_ID); getchar(); info=find(Room_ID); if(!info) printf(" t can't findn"); else display(info); search2() s
19、truct Hotel *info; char a10="null" info=start; while(info) if(!strcmp(info->person,a) display(info); printf("n"); info=info->next; search3() struct Hotel *info; char b10="have" info=start; while(info) if(!strcmp(b,info->person) display(info); printf(" n &q
20、uot;); info=info->next; save() register int t,size; struct Hotel *info; char *p; FILE *fp; if(fp=fopen("mlist","wb")=0) printf(" t file can't openn"); exit(0); printf("t savingn"); size=sizeof(RoomNUM); info=start; while(info) p=(char*)info; for(t=0;t&l
21、t;size;+t) putc(*p+,fp); info=info->next; putc(EOF,fp); fclose(fp); printf("t savedn"); .4修改模塊該模塊的功能是顯示用戶(hù)要修改的信息。用戶(hù)輸入要修改的信息,根據(jù)輸入信息查對(duì)應(yīng)選項(xiàng),并提示用戶(hù)修改該記錄的那部分信息,根據(jù)用戶(hù)的選項(xiàng)修改相應(yīng)的信息。流程圖用戶(hù)輸入要修改的信息i!=o嗎? 顯示找到的記錄調(diào)用修改記錄 返回開(kāi)始NY詢(xún)問(wèn)用戶(hù)是否繼續(xù)修改 提示沒(méi)有找到對(duì)應(yīng)修改信息 NY程序modify() /*修改模塊*/ struct Hotel *info; char Room_ID10
22、; char a10="have" char c10="null" int b,f; printf(" t examine the information 1n"); /*檢驗(yàn)信息*/ printf(" t change the information 2n"); /*修改信息*/ printf(" t back to the main menu 3n"); /*返回主菜單*/ scanf("%d",&b); if(b=1)search(); if(b=2) prin
23、tf(" t put the Room_IDn"); scanf("%s",Room_ID); info=find(Room_ID); if(!info)printf("t can't findn"); else display(info);printf("t Change Entry n"); if(!strcmp(a,info->person) inputs("t put null:n",info->person,10); if(!strcmp(c,info->pe
24、rson) inputs("t name:n",info->Client_list.Name,20); inputs("t sex:n",info->Client_list.Sex,10); inputs("t age:n",info->Client_list.Age,10); inputs("t Id_card:n",info->Client_list.ID_card,20); inputs("t year:n",info->Client_list.year,10
25、); inputs("t month:n",info->Client_list.month,10); inputs("t date:n",info->Client_list.date,10); inputs("t Tel:n",info->Tel,10); inputs("t Price:n",info->Price,10); if(b=3) return; 退出模塊該模塊需要有保存,退出,返回三個(gè)操作。程序顯示一系列功能選項(xiàng)輸入n,判斷n是否是3?根據(jù)n的值調(diào)用各功能模塊函
26、數(shù)結(jié)束開(kāi)始NY程序tuichu() /*退出模塊*/ int d; printf("t suggest you save the message,if save put 1,sure to exit put 2 ,back to main menu put 3n"); scanf("%d",&d); if(d=1) save(); /*保存*/ if(d=2) printf("t Thank you for useing the system!n"); /*退出*/ if(d=3) printf("t backn"); /*返回*/ exit(0); 3. 學(xué)習(xí)心得在老師的帶領(lǐng)下進(jìn)行了C語(yǔ)言程序?qū)嵺`學(xué)習(xí)。在短短一周的實(shí)習(xí)期間使我獲取了不少新知識(shí)也鞏固了許多老知識(shí)。在這之前,我們已經(jīng)對(duì)C語(yǔ)言這門(mén)課程學(xué)習(xí)了一個(gè)學(xué)期,對(duì)其有了一定的了解,但是也僅僅是停留在學(xué)習(xí)了解的范圍,對(duì)
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 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ì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 攝影圖片教學(xué)課件
- 特定地質(zhì)條件下采石場(chǎng)經(jīng)營(yíng)權(quán)轉(zhuǎn)移協(xié)議
- 高效車(chē)庫(kù)購(gòu)置及管理服務(wù)合同
- 礦產(chǎn)資源采礦權(quán)質(zhì)押借款合同范本下載
- 班主任學(xué)生國(guó)際交流項(xiàng)目聘用協(xié)議
- 大數(shù)據(jù)應(yīng)用采購(gòu)合同數(shù)據(jù)版
- 財(cái)務(wù)管理考試題及答案2025
- 餐飲行業(yè)特色服務(wù)人員派遣及培訓(xùn)合同
- 餐飲行業(yè)勞動(dòng)合同范本(含員工培訓(xùn)與考核制度)
- 出租車(chē)客運(yùn)市場(chǎng)拓展承包合作協(xié)議
- 軟件開(kāi)發(fā)項(xiàng)目進(jìn)度管理
- CNAS-CL01-2018內(nèi)審檢查記錄表
- 《無(wú)人機(jī)駕駛航空試驗(yàn)基地(試驗(yàn)區(qū))基礎(chǔ)設(shè)施建設(shè)規(guī)范(征求意見(jiàn)稿)》
- 衍射概念與布拉格方程
- 山東農(nóng)業(yè)工程學(xué)院輔導(dǎo)員考試試題2024
- 高中英語(yǔ)人教版必修二單詞(分單元編排)
- 初中家庭教育指導(dǎo)案例
- 翡翠店面計(jì)劃書(shū)
- 嚴(yán)重精神障礙患者家庭護(hù)理培訓(xùn)課件
- 電能表的接線檢查-相量圖法 (1).電能表的接線檢查-相量圖法
- 廣告安裝培訓(xùn)課件
評(píng)論
0/150
提交評(píng)論