當前位置:法律諮詢服務網 - 企業資訊 - C語言實現酒店信息管理系統

C語言實現酒店信息管理系統

不知道妳的要求是什麽,把我以前的關於酒店管理的代碼發給妳參考下吧。

#include<string.h>?

#include<stdlib.h>

#include<stdio.h>?

#include<conio.h>?

typedef?struct?tagCustomer

{

char?m_ID[19];?/*身份證號碼*/

char?m_name[10];/*顧客姓名*/

int?m_age;/*顧客年齡*/

char?m_sex[6];/*顧客性別*/

int?num;

}Customer;/*顧客結構*/

typedef?struct?tagRoom

{

int?m_num;?/*房間號*/

int?m_floor;/*樓層*/

int?m_price;/*價格*/

int?m_use;?/*是否已入住*/

}Room;/*房間結構*/

int?i,j=0,age,num,floor,price,use,n;

int?reg?=0;

Customer?cus[5];

Roomr[5];

int?count=5;

char?ID[18],name[10],sex[6];

FILE?*fproom;

FILE?*fpcustomer;

void?Customer_Input()

{

if(count<=5)

{

printf("請輸入身份證號(18位數字):");

scanf("%s",&cus[j].m_ID);

printf("請輸入姓名(10位字符)");

scanf("%s",&cus[j].m_name);

printf("請輸入年齡(數字型)");

scanf("%d",&cus[j].m_age);

printf("請輸入性別(男或女):");

scanf("%s",&cus[j].m_sex);

}

else

{

printf("\n?存儲空間已滿!");

}

printf("\n\r顧客可以住在:");

printf("\n\r房間號樓層價格是否空閑(1:空閑0:已使用)");

for(i=0;i<count;i++)

{

if(r[i].m_use==1)

{

printf("\n\r%d?%d%d%d?",r[i].m_num,r[i].m_floor,r[i].m_price,r[i].m_use);

}

}

printf("\n\r請妳輸入房間號:");

scanf("%d",&num);

reg?=?0;

for(i=0;i<count;i++)

{

if(r[i].m_use==1&&r[i].m_num==num)

{

r[i].m_use?=?0;

printf("\n?登記成功!\n");

cus[j].num=r[i].m_num?;

j=j+1;

reg=1;

}

}

if(reg==0)

{

printf("\n?登記失敗!\n");

}

}

void?Customer_ListOut()

{

if(count<=5)

{

printf("請輸入身份證號(18位數字):");

scanf("%s",&ID);

for(i=0;i<count;i++)

{

if(strcmp(cus[i].m_ID,ID)==0)

{

printf("\n\r顧客身份證號:%s姓名:%s年齡:%d性別:%s?\n",cus[i].m_ID,cus[i].m_name,cus[i].m_age,cus[i].m_sex);

}

}

}

else

{

printf("\n?\n");

}

}

void?Room_ListOut()

{

printf("\n\r房間號樓層價格是否空閑(1:空閑0:已使用)");

for(i=0;i<count;i++)

{

if(r[i].m_use==1)

{

printf("\n\r%d?%d%d%d?",r[i].m_num,r[i].m_floor,r[i].m_price,r[i].m_use);

}

}

}

void?PerCustomer_Search()

{

if(count<=5)

{

printf("請輸入身份證號(18位數字):");

scanf("%s",&cus[j].m_ID);

printf("請輸入姓名(10位字符)");

scanf("%s",&cus[j].m_name);

printf("請輸入年齡(數字型)");

scanf("%d",&cus[j].m_age);

printf("請輸入性別(男或女):");

scanf("%s",&cus[j].m_sex);

}

else

{

printf("\n?住房已滿!");

}

printf("\n\r顧客可以預訂:");

printf("\n\r房間號樓層價格是否空閑(1:空閑0:已使用)");

for(i=0;i<count;i++)

{

if(r[i].m_use==1)

{

printf("\n\r%d?%d%d%d?",r[i].m_num,r[i].m_floor,r[i].m_price,r[i].m_use);

}

}

printf("\n?請妳輸入要預訂的房間號:");

scanf("%d",&num);

reg?=?0;

for(i=0;i<count;i++)

{

if(r[i].m_use==1&&r[i].m_num==num)

{

r[i].m_use?=?0;

printf("\n?預訂成功!\n");

cus[j].num=r[i].m_num?;

j=j+1;

reg=1;

}

}

if(reg==0)

{

printf("\n?預訂失敗!\n");

}

}

void?UnCustomer_Out()

{

int?k;

printf("\n?請輸入要退房顧客身份證:");

scanf("%s",&ID);

for(i=0;i<count;i++)

{

if(strcmp(cus[i].m_ID,ID)==0)

{

printf("\n\r顧客身份證號:%s姓名:%s年齡:%d性別:%s?\n\r已經成功退房!",cus[i].m_ID,cus[i].m_name,cus[i].m_age,cus[i].m_sex);

for(k=0;k<count;k++)

if(r[k].m_num==cus[i].num)

r[k].m_use=1;

memset(&cus[i],0,sizeof(Customer));

}

}

}

void?Customer_Goaway()

{

fproom=fopen("room","wb+");

fwrite((void?*)&r,sizeof(Room),count,fproom);

fclose(fproom);

fpcustomer=fopen("customer","wb+");

fwrite((void?*)&r,sizeof(Room),count,fpcustomer);

fclose(fpcustomer);

exit(0);

}

main()

{

fproom=fopen("room","wb");

if(fproom!=NULL)

{

for(i=0;i<count;i++)

{

int?id=100;

r[i].m_num=i+100;

r[i].m_floor=1;

r[i].m_price=100;

r[i].m_use=1;

}

fwrite((void?*)&r,sizeof(Room),count,fproom);

fclose(fproom);

}

else

{

printf("\n---文件打開失敗--");

}

for(;;)

{

printf("\n");

printf("/******************************************\\\n");

printf("*?*\n");

printf("*酒店管理系統*\n");

printf("*?主菜單?*\n");

printf("*?*\n");

printf("*1.顧客登記*\n");

printf("*2.查詢顧客信息*\n");

printf("*3.查詢空房間?*\n");

printf("*4.預訂房間*\n");

printf("*5.退訂房間*\n");

printf("*6.保存並退出系統?*\n");?

printf("*?*\n");

printf("\\******************************************/\n\n");

printf("請輸入選擇項(1-6):");

scanf("%d",&n);

printf("\n\n\n\n");

if(n>0&&n<=6)

{

switch(n)

{

case?1:Customer_Input();break;

case?2:Customer_ListOut();break;/*查詢顧客信息*/

case?3:Room_ListOut();break;/*查詢空房間*/

case?4:PerCustomer_Search();break;/*預訂房間*/

case?5:UnCustomer_Out();break;/*退訂房間*/

case?6:Customer_Goaway();?/*保存退出*/

}

}

else?

{

printf("***********************************************************************\n");

printf("*?*\n");

printf("*?輸入錯誤!*\n");

printf("*?請退出!?*\n");

printf("*?*\n");

printf("***********************************************************************\n");

break;

}

}

}

  • 上一篇:夢見烤紅薯是什麽意思?
  • 下一篇:妳好,我也收到了普邦花園的培訓通知,但是地點是廣東韶關。妳最後壹次是什麽時候?謝謝妳。
  • copyright 2024法律諮詢服務網