語言旅館信息管理系統(tǒng)_第1頁
語言旅館信息管理系統(tǒng)_第2頁
語言旅館信息管理系統(tǒng)_第3頁
語言旅館信息管理系統(tǒng)_第4頁
語言旅館信息管理系統(tǒng)_第5頁
已閱讀5頁,還剩7頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

1、/*題目:旅店信息管理系統(tǒng)*小組成員:閆若琳 戴雨晨 馬淵沐 張子飛 李闖 王浩 崔以博 孫浩浩 李春普 溫健成*/#include <stdio.h>#include <conio.h>#include <stdlib.h>#include <string.h>#define MIN 1#define MAX 30#define LEN sizeof(struct Hotel)/用LEN代替結(jié)構(gòu)體的"長度"void regeist();void out_information();void search_number();v

2、oid show_all();void search_name();void change();void fire();struct Hotel *load();FILE *fp; struct Hotel int room_number;char name 20;char sex10;char ID 20;float paid10;int inyear ;int inmonth ;int inday ;struct Hotel *next ;struct Hotel *load() /定義load函數(shù)讀取當(dāng)前的信息,并存到內(nèi)存鏈表中struct Hotel *head,*pb, *s ;pb

3、=(struct Hotel *)malloc(LEN); /開辟新的節(jié)點(diǎn)s =(struct Hotel *)malloc(LEN);if(pb=NULL)|(s=NULL)printf ("動(dòng)態(tài)內(nèi)存分配失??!n");getch();exit(0);if(fp=fopen("resturant.txt","rb")=NULL)printf ("無法打開文件!n");getch();exit(0);head = pb;while (fread (s,LEN,1,fp) /讀取當(dāng)前的信息,并存到鏈表中pb->n

4、ext = s;pb = s;s = (struct Hotel *)malloc(LEN);pb->next =NULL;return head ;/返回鏈表的頭指針int main ()/崔以博、孫浩浩 char choice ;do printf ("nn-歡迎使用旅店信息管理系統(tǒng)-nn"); printf ("1.查看旅店信息n2.查看某一房間信息n3.查看旅客信息n"); printf ("4.查找某一旅客信息n5.旅客入住n6.旅客換房n7.旅客退房n8.退出n"); printf ("n-n")

5、; choice=getch();switch (choice) case '1':out_information();break; case '2':search_number();break; case '3':show_all();break; case '4':search_name();break; case '5':regeist();break; case '6':change();break; case '7':fire();break; case '8

6、9;:exit(0);break; default :printf ("Error !");break ;printf ("nn請按任意鍵繼續(xù) !n");getch();system("cls");while(1);return 0 ;void out_information()/張子飛:定義out_information函數(shù),完成查看旅店信息功能FILE *fp;char ch ;if (fp=fopen("information.txt","r")=NULL) printf ("無

7、法打開文件!n");getch(); exit(0);ch=fgetc(fp);system("cls");printf("nnttt旅店信息介紹: (若沒有信息請返回創(chuàng)建)");printf ("n-nnt");while (ch!=EOF)putchar(ch);ch=fgetc(fp);fclose(fp);void search_number ()/李春普、溫健成:定義search_number函數(shù),用來完成查看某一房間的信息char ch2 ;int room_number ;struct Hotel *head,

8、 *pa ;head=load();printf ("n請輸入需要查看的房間序號(hào):(%d%d):",MIN,MAX);scanf ("%d",&room_number);pa= head->next;if (room_number<MIN|room_number>MAX)printf ("anError!");return ;doif (pa)if(room_number=pa->room_number)/如果找到相應(yīng)信息,則輸出printf ("n");printf ("

9、roomnumber:t%d",pa->room_number);printf ("n");printf ("name:tt%s",pa->name);printf ("n");printf ("sex:tt%s",pa->sex);printf ("n");printf ("ID:tt%s",pa->ID);printf ("n");printf ("paid:tt%s",pa->paid);p

10、rintf ("n");printf ("%d %d %d",pa->inyear,pa->inmonth,pa->inday);printf ("n");printf ("n請選擇是否繼續(xù)查看信息(y/n):n");scanf ("%s",ch);if(strcmp(ch,"Y")!=0)&&(strcmp(ch,"y")!=0)return;elseprintf ("n請輸入需要查看的房間序號(hào):(%d%d):

11、",MIN,MAX);scanf ("%d",&room_number);pa= head->next;if (room_number<MIN|room_number>MAX)printf (" 無此房間!");return;continue ;pa = pa->next;elseprintf ("n該房間還沒有旅客入住");return;while(1);void show_all()/戴雨晨:定義是show_all函數(shù),用來顯示所有旅客信息struct Hotel *head, *pa ;

12、head=load();pa= head->next;printf ("n所有入住旅客的信息如下:n");while (pa)/顯示所有的旅客信息printf ("n");printf ("roomnumber:t%d",pa->room_number);printf ("n");printf ("name:tt%s",pa->name);printf ("n");printf ("sex:tt%s",pa->sex);printf

13、 ("n");printf ("ID:tt%s",pa->ID);printf ("n");printf ("paid:tt%s",pa->paid);printf ("n");printf ("date:tt%d %d %d",pa->inyear,pa->inmonth,pa->inday);printf ("n");pa = pa->next;void search_name ()/馬淵沐:定義search_nam

14、e函數(shù),用來完成查看某一旅客的信息char ch2 ;char inname20 ;/用數(shù)組inname20來儲(chǔ)存需要查詢的旅客namestruct Hotel *head, *pa ;head=load();printf ("n請輸入需要查看的旅客姓名:");scanf ("%s",inname);pa= head->next;doif (pa)if(strcmp(inname,pa->name)=0)printf ("n");printf ("roomnumber:t%d",pa->room_

15、number);printf ("n");printf ("name:tt%s",pa->name);printf ("n");printf ("sex:tt%s",pa->sex);printf ("n");printf ("ID:tt%s",pa->ID);printf ("n");printf ("paid:tt%s",pa->paid);printf ("n");printf (&qu

16、ot;date:tt%d %d %d",pa->inyear,pa->inmonth,pa->inday);printf ("n");printf ("n請選擇是否繼續(xù)查看信息(y/n):n");scanf ("%s",ch);if(strcmp(ch,"Y")!=0)&&(strcmp(ch,"y")!=0)return;elseprintf ("n請輸入需要查看的旅客姓名:");scanf ("%s",inn

17、ame);pa= head->next;continue ;pa = pa->next;else printf ("n沒有查到該旅客的信息");return ;while(1);void regeist()/閆若琳:定義regeist函數(shù)實(shí)現(xiàn)入住功能char ch2 ;int number ;struct Hotel *head,*p1,*p2,*pa;head=load();pa= head->next;printf ("n已入住房間:n");while (pa)printf ("n");printf ("

18、;roomnumber:t%d",pa->room_number);pa = pa->next; fclose(fp);if(fp=fopen("resturant.txt","a+")=NULL)printf ("無法打開文件!n");getch();exit(0);head=NULL;p1=(struct Hotel *)malloc(LEN);p2=(struct Hotel *)malloc(LEN);if (p1=NULL)|(p2=NULL)printf ("動(dòng)態(tài)內(nèi)存分配失??!n"

19、);getch();exit(0);printf ("n請登記入住信息!n");printf ("請選擇房間號(hào)(%d%d):",MIN,MAX);scanf ("%d",&number);if (number<MIN|number>MAX)printf ("無此房間!");return;p1->room_number=number ;/在該房間沒有旅客時(shí),登記入住printf ("name:t");scanf ("%s",&p1->na

20、me);printf ("sex:t");scanf ("%s",&p1->sex);printf ("ID:t"); scanf ("%s",&p1->ID);printf ("paid:t");scanf ("%s",&p1->paid);printf ("date(年月日空格隔開):");scanf ("%d %d %d",&p1->inyear,&p1->in

21、month,&p1->inday);p1->next=NULL ;if(head=NULL)/將輸入的信息保存到鏈表head=p1;p2=p1 ;elsep2->next=p1;p2=p1 ;fwrite(p2,LEN,1,fp);fclose (fp); /將鏈表信息保存到磁盤文件printf ("n請選擇是否繼續(xù)登記信息 (y/n):");/判斷是否繼續(xù)登記旅客信息scanf ("%s",ch);if(strcmp(ch,"y")!=0)printf ("n登記旅客入住信息成功!");

22、return(0);else regeist();return ;/登記完成后返回頭鏈表指針void change() /李創(chuàng):定義change函數(shù)實(shí)現(xiàn)換房功能int room_number ;int newroom_number ;struct Hotel *head, *pa,*L ;head=load();printf ("n請輸入需要換房的房間序號(hào):(%d%d):",MIN,MAX);scanf ("%d",&room_number);if (room_number<MIN|room_number>MAX)printf (&q

23、uot;無此房間!");getch();return;pa= head->next; doif (pa)if(room_number=pa->room_number)printf ("n");printf ("roomnumber:t%d",pa->room_number);printf ("n");printf ("name:tt%s",pa->name);printf ("n");printf ("sex:tt%s",pa->sex

24、);printf ("n");printf ("ID:tt%s",pa->ID);printf ("n");printf ("paid:tt%s",pa->paid);printf ("n");printf ("date:tt%d %d %d",pa->inyear,pa->inmonth,pa->inday);printf ("n");printf ("n請輸入需要換到的房間序號(hào):(%d%d):",MIN

25、,MAX);scanf ("%d",&newroom_number);if (newroom_number<MIN|newroom_number>MAX)printf ("無此房間!");getch();return;pa->room_number=newroom_number ;break ;pa = pa->next;elseprintf ("n該房間還沒有旅客入??!n");getch();return;while(1);fclose(fp);if(fp=fopen("resturant.

26、txt","wb")=NULL)printf ("無法打開文件!n");getch();exit(0);L=head->next;while(L)fwrite(L,LEN,1,fp);L=L->next ;fclose(fp);printf ("n換房成功!");return;void fire() /王浩:定義fire函數(shù)實(shí)現(xiàn)退房功能char inname20 ;/用數(shù)組inname20來儲(chǔ)存需要退房旅客namestruct Hotel *head, *qian,*pa,*L ;head=load();qian=(struct Hotel *)malloc(LEN); /開辟新的節(jié)點(diǎn)if (qian=NULL)printf ("動(dòng)態(tài)內(nèi)存分配失??!n");/如果動(dòng)態(tài)內(nèi)存分配失敗,返回失敗信息getch();exit(0);printf ("n請輸入需要退房的旅客姓名:");scanf ("%s",inname);pa=head->next ;doif (pa)if(strcmp(inname,pa->name)=0)printf

溫馨提示

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

評(píng)論

0/150

提交評(píng)論