欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C語言實(shí)現(xiàn)酒店管理系統(tǒng)

 更新時(shí)間:2022年06月05日 10:47:35   作者:npine  
這篇文章主要為大家詳細(xì)介紹了C語言實(shí)現(xiàn)酒店管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了C語言實(shí)現(xiàn)酒店管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

系統(tǒng)框架:

代碼:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int dan=988,shuang=1299,tao=2998;//初始房間價(jià)格
int sdan=1000,sshuang=600,stao=200;//初始房間數(shù)量
int Day;//天數(shù)
int num=0;//客戶數(shù)量
long N=10000000;//現(xiàn)金流
struct DINGDAN//訂單結(jié)構(gòu)體
{
? ? long hao;//訂單號
? ? struct YHXX *p;//客戶信息結(jié)構(gòu)體地址
};
struct DINGDAN Dingdan[2000];
struct YHXX//客戶信息結(jié)構(gòu)體
{
? ? char ID[18];
? ? char name[10];
? ? char sex;//性別
? ? int rooms;//房間數(shù)
? ? char rooml;//房間類型
? ? int rday[3];//入住日期
? ? int sday;//住宿時(shí)間
? ? long dingdanhao;//訂單號
};
struct YHXX yhxx[2000];
void zhucaidan()//主菜單
{
? ? printf("\n\n");
? ? printf("\t\t******大壯酒店管理系統(tǒng)******\n");
? ? printf("\t\t* ? ? 1.:用戶信息查詢 ? ? ?*\n");
? ? printf("\t\t* ? ? 2.:客房經(jīng)營管理 ? ? ?*\n");
? ? printf("\t\t* ? ? 3.:客房管理 ? ? ? ? ?*\n");
? ? printf("\t\t****************************\n\n");
}
void caidan1()//用戶信息查詢菜單
{
? ? printf("\n");
? ? printf("\t\t--------用戶信息查詢--------\n");
? ? printf("\t\t* ? ? 1.:按訂單號查詢 ? ? ?*\n");
? ? printf("\t\t* ? ? 2.:按姓名查詢 ? ? ? ?*\n");
? ? printf("\t\t* ? ? 3.:按身份證號查詢 ? ?*\n");
? ? printf("\t\t* ? ? 4.:用戶信息目錄 ? ? ?*\n");
? ? printf("\t\t----------------------------\n\n");
}
void caidan2()//客房經(jīng)營管理菜單
{
? ? printf("\n");
? ? printf("\t\t--------客房經(jīng)營管理--------\n");
? ? printf("\t\t* ? ? 1.:預(yù)定客房或登記入住*\n");
? ? printf("\t\t* ? ? 2.:退房操作 ? ? ? ? ?*\n");
? ? printf("\t\t* ? ? 3.:客房狀態(tài) ? ? ? ? ?*\n");
? ? printf("\t\t----------------------------\n\n");
}
void caidan3()//房間管理菜單
{
? ? printf("\n");
? ? printf("\t\t----------房間管理----------\n");
? ? printf("\t\t* ? ? ? ?1.:更改房價(jià) ? ? ? *\n");
? ? printf("\t\t* ? ? ? ?2.:增加客房 ? ? ? *\n");
? ? printf("\t\t* ? ? ? ?3.:減少客房 ? ? ? *\n");
? ? printf("\t\t----------------------------\n\n");
}
void save()
{
? ? FILE *fp;
? ? //int i;
? ? if((fp=fopen("kehu","wb"))==NULL)//打開輸出文件
? ? {
? ? ? ? printf("\t\tcannot open file\n");
? ? ? ? return;
? ? }
? ? fseek(fp,0L,2);
? ? if(fwrite(&yhxx[num],sizeof(struct YHXX),1,fp)!=1)
? ? ? ? printf("\t\tfile write error\n");
? ? fclose(fp);//關(guān)閉wenj
}
void print()
{
? ? int i,t=0;
? ? FILE *fp;
? ? if((fp=fopen("kehu.dat","wb"))==NULL)//打開輸入文件
? ? {
? ? ? ? printf("cannot open file\n");
? ? ? ? exit(0);
? ? }
? ? rewind(fp);//使文件位置標(biāo)記返回文件開頭
? ? for(i=0;i<num;i++)
? ? ? ? {
? ? ? ? ? ? fread(&yhxx[i],sizeof(struct YHXX),1,fp);
? ? ? ? ? ? printf("\t\t姓名:%s\t",yhxx[i].name);
? ? ? ? ? ? if(yhxx[i].sex=='Y') printf("性別: 男\(zhòng)n");
? ? ? ? ? ? else printf("性別 女\n");
? ? ? ? ? ? printf("\t\t身份證號:%s\n",yhxx[i].ID);
? ? ? ? ? ? printf("\t\t入住日期: %d %d %d",yhxx[i].rday[0],yhxx[i].rday[1],yhxx[i].rday[2]);
? ? ? ? ? ? printf(" ?入住時(shí)間: %d\n",yhxx[i].sday);
? ? ? ? ? ? t=1;
? ? ? ? }
? ? ? ? if(t==0) printf("\t\t ?無用戶信息!\n");
? ? ? ? fclose(fp);//關(guān)閉文件
}
void H()//更改房價(jià)
{
? ? int x;
?? ?char ch;
Hto:
?? ?printf("\t\t豪華單間:D ?豪華雙人:S ?貴賓套房:T\n");
?? ?printf("\t\t請輸入房間類型和更改后價(jià)格: ");
?? ?scanf("%c %d",&ch,&x);
?? ?switch(ch)
?? ?{
?? ??? ?case 'D':dan=x;break;
?? ??? ?case 'S':shuang=x;break;
?? ??? ?case 'T':tao=x;break;
? ? ? ? default : goto Hto;
?? ?}
?? ?printf("\t\t更改后分別為:\n\t\t%d %d %d\n\t\t",dan,shuang,tao);
}
void I()//增加客房
{
? ? int x;
?? ?char ch;
Ito:
?? ?printf("\t\t豪華單間:D ?豪華雙人:S ?貴賓套房:T\n");
?? ?printf("\t\t請輸入房間類型和增加數(shù)量: ");
?? ?scanf("%c %d",&ch,&x);
?? ?switch(ch)
?? ?{
?? ??? ?case 'D':sdan+=x;break;
?? ??? ?case 'S':sshuang+=x;break;
?? ??? ?case 'T':stao+=x;break;
? ? ? ? default : goto Ito;
?? ?}
?? ?printf("\t\t更改后分別為:%d %d %d\n\t\t",sdan,sshuang,stao);
}
void J()//減少客房
{
? ? int x;
?? ?//int sdan=1000,sshuang=600,stao=200;
?? ?char ch;
Jto:
?? ?printf("\t\t豪華單間:D ?豪華雙人:S ?貴賓套房:T\n");
?? ?printf("\t\t請輸入房間類型和減少數(shù)量: ");
?? ?scanf("%c %d",&ch,&x);
?? ?switch(ch)
?? ?{
?? ??? ?case 'D':sdan-=x;break;
?? ??? ?case 'S':sshuang-=x;break;
?? ??? ?case 'T':stao-=x;break;
? ? ? ? default : goto Jto;
?? ?}
?? ?printf("\t\t更改后分別為:%d %d %d\n\t\t",sdan,sshuang,stao);
}
void DE()//預(yù)定客房或登記入住
{
? ? char lroom;
? ? int sroom;
? ? int jiner=0;
? ? printf("\t\t訂房功能\n");
? ? to:
? ? printf("\t\t豪華單間:D ?豪華雙人:S ?貴賓套房:T\n");
? ? printf("\t\t請輸入房間類型:");
? ? getchar();
? ? scanf("%c",&lroom);
? ? printf("\t\t數(shù)量:");
? ? scanf("%d",&sroom);
? ? switch(lroom)
? ? {
? ? ? ? case 'D':jiner=sroom*dan;sdan-=sroom;break;
? ? ? ? case 'S':jiner=sroom*shuang;sshuang-=sroom;break;
? ? ? ? case 'T':jiner=sroom*tao;stao-=sroom;break;
? ? ? ? default:goto to;
? ? }
? ? if((lroom=='D'&&sroom<=sdan)||(lroom=='S'&&sroom<=sshuang)||(lroom=='T'&&sroom<=stao))
? ? {
? ? ? ? printf("\t\t請輸入您的信息: \n");
? ? ? ? printf("\t\t姓名: ");
? ? ? ? scanf("%s",yhxx[num].name);
? ? ? ? getchar();
? ? ? ? printf("\t\t性別: (男:Y ?女:X) :");
? ? ? ? scanf("%c",&yhxx[num].sex);
? ? ? ? printf("\t\t身份證ID: ");
? ? ? ? scanf("%s",yhxx[num].ID);
? ? ? ? printf("\t\t入住日期: ");
? ? ? ? scanf("%d %d %d",&yhxx[num].rday[0],&yhxx[num].rday[1],&yhxx[num].rday[2]);
? ? ? ? printf("\t\t入住時(shí)間: ");
? ? ? ? scanf("%d",&yhxx[num].sday);
? ? ? ? printf("\t\t訂單總額:%d\n",jiner*yhxx[num].sday);
? ? ? ? N+=jiner;jiner=0;
? ? ? ? yhxx[num].rooms=sroom;
? ? ? ? yhxx[num].rooml=lroom;
? ? ? ? yhxx[num].dingdanhao=100000+num;//生成訂單號;
? ? ? ? save();
? ? ? ? Dingdan[num].hao=yhxx[num].dingdanhao;//插入訂單號到訂單號結(jié)構(gòu)體;
? ? ? ? Dingdan[num].p=&yhxx[num];//將客戶信息結(jié)構(gòu)體地址插入到訂單結(jié)構(gòu)體中;
? ? ? ? printf("\t\t訂單號:%ld\n",yhxx[num].dingdanhao);
? ? ? ? num++;
? ? ? ? printf("\t\t訂購成功!\n");
? ? }
}
void F()//退房操作
{
? ? int i,j,t=0;
? ? char name1[10],ID1[18];
? ? printf("\t\t退房操作:\n");
? ? printf("\t\t請輸入姓名: ");
? ? scanf("%s",name1);
? ? printf("\n\t\t請輸入身份證號:");
? ? scanf("%s",ID1);
? ? for(i=0;i<num;i++)
? ? {
? ? ? ? if(strcmp(name1,yhxx[i].name)==0&&strcmp(ID1,yhxx[i].ID)==0)
? ? ? ? {
? ? ? ? ? ? switch(yhxx[i].rooml)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? case 'D':N-=yhxx[i].rooms*dan;
? ? ? ? ? ? ? ? case 'S':N-=yhxx[i].rooms*shuang;
? ? ? ? ? ? ? ? case 'T':N-=yhxx[i].rooms*tao;
? ? ? ? ? ? }
? ? ? ? ? ? for(j=i-1;i<num;j++,i++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ?strcpy(yhxx[j].ID,yhxx[i].ID);
? ? ? ? ? ? ? ?strcpy(yhxx[j].name,yhxx[i].name);
? ? ? ? ? ? ? ?yhxx[j].sex=yhxx[i].sex;
? ? ? ? ? ? ? ?yhxx[j].rooms=yhxx[i].rooms;
? ? ? ? ? ? ? ?yhxx[j].rooml=yhxx[i].rooml;
? ? ? ? ? ? ? ?yhxx[j].sday=yhxx[i].sday;
? ? ? ? ? ? ? ?yhxx[j].rday[0]=yhxx[i].rday[0];
? ? ? ? ? ? ? ?yhxx[j].rday[1]=yhxx[i].rday[1];
? ? ? ? ? ? ? ?yhxx[j].rday[1]=yhxx[i].rday[1];
? ? ? ? ? ? }
? ? ? ? ? ? num--;
? ? ? ? ? ? t=1;
? ? ? ? ? ? break;
? ? ? ? }
? ? ? ? else printf("\t\t查詢到無此用戶!");
? ? }
? ? if(t==1)printf("\t\t退房成功!\n");
}
void G()//客房狀態(tài)
{
? ? printf("\t\t空余客房:豪華單間:%d 豪華雙間:%d 豪華套房:%d\n",1000-sdan,600-sshuang,200-stao);
? ? printf("\t\t\t現(xiàn)金流:%ld\n",N);
}
void A()//按訂單號查詢
{
? ? int i,t=0;
? ? long h;
? ? struct YHXX *p0;
? ? printf("\t\t請輸入訂單號:");
? ? scanf("%ld",&h);
? ? for(i=0;i<num;i++)
? ? {
? ? ? ? if(h==Dingdan[i].hao)
? ? ? ? {
? ? ? ? ? ? p0=Dingdan[i].p;
? ? ? ? ? ? printf("\t\t姓名:%s\t",p0->name);
? ? ? ? ? ? if(p0->sex=='Y') printf("性別: 男\(zhòng)n");
? ? ? ? ? ? else printf("性別 女\n");
? ? ? ? ? ? printf("\t\t身份證號:%s ",p0->ID);
? ? ? ? ? ? switch(yhxx[i].rooml)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? case 'D':printf(" 豪華單間: %d\n",p0->rooms);break;
? ? ? ? ? ? ? ? case 'S':printf(" 豪華雙間: %d\n",p0->rooms);break;
? ? ? ? ? ? ? ? case 'T':printf(" 豪華套房: %d\n",p0->rooms);break;
? ? ? ? ? ? }
? ? ? ? ? ? printf("\t\t入住日期: %d %d %d",p0->rday[0],p0->rday[1],p0->rday[2]);
? ? ? ? ? ? printf(" ?入住時(shí)間: %d\n",p0->sday);
? ? ? ? ? ? t=1;
? ? ? ? ? ? break;
? ? ? ? }
? ? }
? ? if(t==0) printf("\t\t客戶信息不存在!\n");
}
void B()//按姓名查詢
{
? ? int i,t=0;
? ? FILE *fp;
? ? char names[10];
? ? printf("\t\t請輸入姓名:");
? ? scanf("%s",names);
? ? if((fp=fopen("kehu.dat","wb"))==NULL)//打開文件
? ? {
? ? ? ? printf("cannot open file\n");
? ? ? ? exit(0);
? ? }
? ? rewind(fp);//使文件位置標(biāo)記返回文件開頭
? ? for(i=0;i<num;i++)
? ? {
? ? ? ? fread(&yhxx[i],sizeof(struct YHXX),1,fp);
? ? ? ? if(strcmp(names,yhxx[i].name)==0)
? ? ? ? {
? ? ? ? ? ? printf("\t\t姓名:%s\t",yhxx[i].name);
? ? ? ? ? ? if(yhxx[i].sex=='Y') printf("性別: 男\(zhòng)n");
? ? ? ? ? ? else printf("性別 女\n");
? ? ? ? ? ? printf("\t\t身份證號:%s",yhxx[i].ID);
? ? ? ? ? ? switch(yhxx[i].rooml)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? case 'D':printf(" 豪華單間: %d\n",yhxx[i].rooms);break;
? ? ? ? ? ? ? ? case 'S':printf(" 豪華雙間: %d\n",yhxx[i].rooms);break;
? ? ? ? ? ? ? ? case 'T':printf(" 豪華套房: %d\n",yhxx[i].rooms);break;
? ? ? ? ? ? }
? ? ? ? ? ? printf("\t\t入住日期: %d %d %d",yhxx[i].rday[0],yhxx[i].rday[1],yhxx[i].rday[2]);
? ? ? ? ? ? printf(" ?入住時(shí)間: %d\n",yhxx[i].sday);
? ? ? ? ? ? t=1;
? ? ? ? ? ? break;
? ? ? ? }
? ? }
? ? if(t==0) printf("\t\t客戶信息不存在!\n");
? ? fclose(fp);//關(guān)閉文件
}
void C()//按身份證號查詢
{
? ? int i,t=0;
? ? FILE *fp;
? ? char ids[10];
? ? printf("\t\t請輸入身份證號:");
? ? scanf("%s",ids);
? ? if((fp=fopen("kehu.dat","wb"))==NULL)//打開文件
? ? {
? ? ? ? printf("cannot open file\n");
? ? ? ? exit(0);
? ? }
? ? rewind(fp);//使文件位置標(biāo)記返回文件開頭
? ? for(i=0;i<num;i++)
? ? {
? ? ? ? fread(&yhxx[i],sizeof(struct YHXX),1,fp);
? ? ? ? if(strcmp(ids,yhxx[i].ID)==0)
? ? ? ? {
? ? ? ? ? ? printf("\t\t姓名:%s\t",yhxx[i].name);
? ? ? ? ? ? if(yhxx[i].sex=='Y') printf("性別: 男\(zhòng)n");
? ? ? ? ? ? else printf("性別 女\n");
? ? ? ? ? ? printf("\t\t身份證號:%s",yhxx[i].ID);
? ? ? ? ? ? switch(yhxx[i].rooml)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? case 'D':printf(" 豪華單間: %d\n",yhxx[i].rooms);break;
? ? ? ? ? ? ? ? case 'S':printf(" 豪華雙間: %d\n",yhxx[i].rooms);break;
? ? ? ? ? ? ? ? case 'T':printf(" 豪華套房: %d\n",yhxx[i].rooms);break;
? ? ? ? ? ? }
? ? ? ? ? ? printf("\t\t入住日期: %d %d %d",yhxx[i].rday[0],yhxx[i].rday[1],yhxx[i].rday[2]);
? ? ? ? ? ? printf(" ?入住時(shí)間: %d\n",yhxx[i].sday);
? ? ? ? ? ? t=1;
? ? ? ? ? ? break;
? ? ? ? }
? ? }
? ? if(t==0) printf("\t\t客戶信息不存在!\n");
? ? fclose(fp);//關(guān)閉文件
}
void zhukongzhi()//主控制函數(shù)
{
? ? int x1,x2;
? ? rrr:
? ? zhucaidan();//首頁菜單
? ? printf("\t\t請輸入選項(xiàng):");
? ? scanf("%d",&x1);
? ? if(x1==1)//用戶信息查詢模塊
? ? {
? ? ? ? qqq:
? ? ? ? caidan1();//用戶信息查詢菜單
? ? ? ? printf("\t\t請輸入選項(xiàng):");
? ? ? ? scanf("%d",&x2);
? ? ? ? switch(x2)
? ? ? ? {
? ? ? ? ? ? case 1:A();break;//按訂單號查詢
? ? ? ? ? ? case 2:B();break;//按姓名查詢
? ? ? ? ? ? case 3:C();break;//按身份證號查詢
? ? ? ? ? ? case 4:print();break;//用戶目錄瀏覽
? ? ? ? ? ? default: goto qqq;//重新輸入
? ? ? ? }
? ? }
? ? else if(x1==2)//客房經(jīng)營管理模塊
? ? {
? ? ? ? www:
? ? ? ? caidan2();//客房經(jīng)營管理菜單
? ? ? ? printf("\t\t請輸入選項(xiàng):");
? ? ? ? scanf("%d",&x2);
? ? ? ? switch(x2)
? ? ? ? {
? ? ? ? ? ? case 1:DE();break;//預(yù)定客房或登記入住
? ? ? ? ? ? case 3:F();break;//退房操作
? ? ? ? ? ? case 4:G();break;//客房狀態(tài)
? ? ? ? ? ? default: goto www;//重新輸入
? ? ? ? }
? ? }
? ? else if(x1==3)//房間管理模塊
? ? {
? ? ? ? eee:
? ? ? ? caidan3();//客房管理菜單
? ? ? ? printf("\t\t請輸入選項(xiàng):");
? ? ? ? scanf("%d",&x2);
? ? ? ? switch(x2)
? ? ? ? {
? ? ? ? ? ? case 1:H();break;//更改房價(jià)
? ? ? ? ? ? case 2:I();break;//增加客房
? ? ? ? ? ? case 3:J();break;//減少客房
? ? ? ? ? ? default: goto eee;//重新輸入
? ? ? ? }
? ? }
? ? else goto rrr;//返回主菜單重新輸入
}
int main()
{
? ? int x=0;
? ? do
? ? {
? ? ? ? zhukongzhi();//進(jìn)入主控制函數(shù);
? ? ? ? printf("\t\t--------是否需要繼續(xù)?--------\n");
? ? ? ? printf("\t\t----回復(fù): 1 (繼續(xù)): 0 (結(jié)束)----\n\t\t請選擇:");
? ? ? ? scanf("%d",&x);
? ? }while(x);
? ? return 0;
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論