c語言酒店管理
Ⅰ 請問高手 用c語言怎樣編程酒店管理系統!
用C# java之類的做啊!!!這樣簡單多了!
有C語言做酒店管理系統==!
要崩潰的!!!
Ⅱ c語言酒店管理系統
20分?我倒
給個建構你,至於怎麼實現自己想辦法了
struct Hotel
{
int index;//客房編號;
int type;//客房類型內;
int position;//客房位置;
int area;//面積;
int bedsOfRoom;//床位數;
int price;//價格容
Hotel*next;
};
Ⅲ 求一篇C語言程序設計酒店管理系統,要求如下
要求對文件操作
可以做一個簡單的文件操作介面
通過使用結構體做為數據將所有信息保存在文件里
添加數據時將結構體寫入文件
查詢時可以循環將文件中的數據讀取到結構體中進行比對查詢
當然如果使用一個數組或鏈表做緩沖區對數據進行緩沖的話會更好一點
完成操作時通過將鏈表數據保存到文件內或者也可以延時保存
如果代碼不想自己寫的話
我可以有償代勞
Ⅳ C語言編寫酒店管理系統
int CheckRoom(struct room *pr)
{char phonenu[4][12]={"110","119","120","122"};/*非法私人電話號碼*/
char type[3][2]={"2","t","T"};
int flag=1,i;
static int pass=1;
if(NULL==pr) {printf("Error:Null point! Can't check the datas:\n");return 0;}
printf("Start to part Maintain:about room\n");
while( strlen(pr->roomnu)>5 )/*檢查數據長度,防止保存二進制數據錯誤*/
{pr->roomnu[5]=0;
printf("ERROR:the roomnu: %s is longer than 5 bytes.\n",pr->roomnu);
printf("Please select another shorter roomnu:\n");
scanf("%s",pr->roomnu);
}
while( strlen(pr->cleaner)>19 )/*檢查數據長度,防止保存二進制數據錯誤*/
{pr->cleaner[19]=0;
printf("ERROR:the cleaner:%s is longer than 19 bytes.\n",pr->cleaner);
printf("Please select another shorter name:\n");
scanf("%s",pr->cleaner);
}
while(flag||strlen(pr->phonenu)>11)/*檢查數據內容(由flag控制)和長度,防止保存二進制數據錯誤*/
{
while( strlen(pr->phonenu)>11 )/*檢查長度*/
{pr->phonenu[11]=0;
printf("ERROR:the phonenu:%s is longer than 11 bytes.\n",pr->phonenu);
printf("Please select another shorter phonenu:\n");
scanf("%s",pr->phonenu);
}
while(flag)/*檢查內容*//*這個演算法也有問題,如果內容非法,但長度通過怎麼辦呢?*/
{for(i=0;flag&&i<4;i++)
if( 0==strcmp(pr->phonenu,phonenu[i]) )/*內容非法*/
{printf("ERROR:illegal phonenu:%s!\n",pr->phonenu);
flag=0;/*檢測到內容非法*/
}
if(flag) flag=0;/*內容檢查通過*/
else {flag=1;
printf("Please input a legal phonenu:\n");
scanf("%s",pr->phonenu);/*內容檢查未通過,重新收入*/
}
}
}
flag=1;
while(flag||strlen(pr->type)>1)/*檢查數據內容(由flag控制)和長度,此例和上例不同*/
{
while( strlen(pr->type)>1 )/*檢查長度*/
{pr->type[1]=0;
printf("ERROR:the type:%s is longer than 1 byte.\n",pr->type);
printf("Please select another shorter type:\n");
scanf("%s",pr->type);
}
while(flag)/*檢查內容*/
{if(strcmp(pr->type,type[0])&&strcmp(pr->type,type[1])&&strcmp(pr->type,type[2]) )/*內容非法*/
{printf("ERROR:illegal type:%s!\n",pr->type);
flag=0;/*檢測到內容非法*/
}
if(flag) flag=0;/*內容檢查通過*/
else {flag=1;
printf("Please input a legal type:\n");
scanf("%s",pr->type);/*內容檢查未通過,重新收入*/
}
}
}
while( pr->maximum<pr->currentclient )/*檢查數據間的聯系*/
{printf("ERROR:the room's capacity does not fit for the number of current clients.\n");
printf("Please alter the maximum:\n");
scanf("%d",&(pr->maximum));
}/*檢查房間最大容量和當前已住顧客人數是否相容,如果前者小於後者則寫入錯誤報告文件 */
printf("Congratulations: ROOM Check pass %d!\n",pass++);
return 1;
}
int CheckClient(struct client *pc)
{ int flag=1,i;
char sex[4][2]={"m","M","f","F"};
static int pass=1;
if(NULL==pc) {printf("Error:Null point! Can't check the datas:\n");return 0;}
printf("Start to part Maintain:about client\n");
while( strlen(pc->roomnu)>5 )/*檢查房間長度*/
{pc->roomnu[5]=0;
printf("ERROR:the roomnu: %s is longer than 5 bytes.\n",pc->roomnu);
printf("Please select another shorter roomnu:\n");
scanf("%s",pc->roomnu);
}
while( strlen(pc->identity_card)!=18 )/*檢查身份證號長度*/
{pc->identity_card[18]=0;
printf("ERROR:the identity_card:%s is not 18 bytes.\n",pc->identity_card);
printf("Please check the length and input it again:\n");
scanf("%s",pc->identity_card);
}
while(strlen(pc->name)>19)/*檢查姓名長度*/
{pc->name[19]=0;
printf("ERROR:the name:%s is longer than 19 bytes.\n",pc->name);
printf("Please select another shorter phonenu:\n");
scanf("%s",pc->name);
}
while(flag||strlen(pc->sex)>1)/*檢查性別內容(由flag控制)和長度*/
{
while( strlen(pc->sex)>1 )/*檢查長度*/
{pc->sex[1]=0;
printf("ERROR:the sex:%s is longer than 1 byte.\n",pc->sex);
printf("Please select another shorter sex:\n");
scanf("%s",pc->sex);
}
while(flag)/*檢查內容*/
{if(strcmp(pc->sex,sex[0])&&strcmp(pc->sex,sex[1])&&strcmp(pc->sex,sex[2])&&strcmp(pc->sex,sex[3]) )/*內容非法*/
{printf("ERROR:illegal sex:%s!\n",pc->sex);
flag=0;/*檢測到內容非法*/
}
if(flag) flag=0;/*內容檢查通過*/
else {flag=1;
printf("Please input a legal sex:\n");
scanf("%s",pc->sex);/*內容檢查未通過,重新收入*/
}
}
}
while( strlen(pc->date)!=8 )/*檢查日期長度*/
{pc->date[8]=0;
printf("ERROR:the date:%s is not 8 bytes.\n",pc->date);
printf("Please check the length and input it again:\n");
scanf("%s",pc->date);
}
while( strlen(pc->collect)>5 )/*檢查收款人長度*/
{pc->collect[5]=0;
printf("ERROR:the collect:%s is not 5 bytes.\n",pc->collect);
printf("Please check the length and input it again:\n");
scanf("%s",pc->collect);
}
while(pc->time<0)/*檢查入住天數*/
{printf("ERROR:illegal input of time: %f!\n",pc->time);
printf("Please check and input it again:\n");
scanf("%f",&pc->time);
}
while(pc->cost<0)/*檢查應繳費用*/
{printf("ERROR:illegal input of cost: %f!\n",pc->cost);
printf("Please check and input it again:\n");
scanf("%f",&pc->cost);
}
while(pc->fee<0)/*檢查實繳費用*/
{printf("ERROR:illegal input of cost: %f!\n",pc->fee);
printf("Please check and input it again:\n");
scanf("%f",&pc->fee);
}
if( pc->fee>pc->cost )/*檢查數據間的聯系,實繳費用應小於應繳用*/
{printf("It may be a error:fee=%f > cost=%f\n",pc->fee,pc->cost);
printf("Do you like to alter them?(1:YES;0:NO)\n");
scanf("%d",&flag);
while(flag)
{printf("Please input the values:cost and fee\n");
scanf("%f%f",&pc->cost,&pc->fee);
if(pc->fee>pc->cost)
{printf("Error again!!\n");flag=1;}
else flag=0;
}
}
printf("Congratulations: CLIENT Check pass %d!\n",pass++);
return 1;
}
int CheckAll(struct room *head_room)
{struct client *pc;
struct room *pr;
if(NULL==head_room) {printf("head_room=0\n");return 0;}
printf("Start to part Maintain:about room and client\n");
pr=head_room;
while(pr)
{CheckRoom(pr);
pc=pr->head;
while(pc)
{CheckClient(pc);
pc=pc->next;
}
pr=pr->next;
}
return 1;
}
/**該函數為內部數據維護,不提供輸入數據服務。實體完整性,參照完整性,用戶自定義完整性
出現錯誤則將錯誤輸出到doc文檔。
錯誤范圍暫時定義如下:
1.同一房間的客戶房間號不同(同房搜索!)
2.實繳費用大於應繳費用。(同房搜索!)
3.同一個客戶在同一天兩次住進賓館(全表搜索!身份證號和入住日期相同)
4.同一身份證號,姓名和性別不同(全表搜索!)
另外,應該完成的任務有:
5.計算客戶的應繳費用->對cost操作,需要用到:time,unit_price
6.計算客房的總住戶人數(包括當前住戶)->對totalclient操作,需要用到:沒有
7.重新修訂當前住戶數->對currentclient進行操作,需要用到:time
8.計算客房的總計收入->對income進行操作,需要用到:fee
9.當前住戶的實繳費用清零->對fee進行操作,需要用到:time
完成這些操作的先後順序為:7->6->5->9->8->2->1->3->4*/
int Consistency(struct room *head_room)
{struct room *pr,*tpr;
struct client *pc,*tpc;
char file[12]="error.doc";
int i=0;/*i用於錯誤計數*/
static int count=0;
FILE *fp;
if(NULL==head_room) {printf("head_room=0\n");return 0;}
printf("Start to part Maintain:Consistency!\n");
pr=head_room;
while(pr)
{pr->currentclient=0;
/*pr->totalclient=0;*/
pr->income=0;
pc=pr->head;
while(pc)
{if(!pc->time) pr->currentclient++;/*完成........7.....*/
/*pr->totalclient++;*/ /*完成........6.....*/
pc->cost=(pc->time)*(pr->unit_price); /*完成........5.....*/
if(!pc->time) pc->fee=0; /*完成........9.....*/
pr->income=pr->income+pc->fee; /*完成........8.....*/
pc=pc->next;
}
pr=pr->next;
}
if(NULL==( fp=fopen(file,"wt") ) )
{printf("Cannot open file:%s!\n",file);
return 0;
}
pr=head_room;
while(pr)
{pc=pr->head;
while(pc)
{if(pc->fee>pc->cost)
{fprintf(fp,"Error %d:fee=%f > cost=%f\n",++i,pc->fee,pc->cost);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",pc->roomnu,pc->identity_card,pc->name,pc->sex,pc->date,pc->collect,pc->time,pc->cost,pc->fee);
/*完成........2.....*/
}
if( strcmp(pr->roomnu,pc->roomnu) )
{fprintf(fp,"Error %d:the client's roomnu:%s != the room's roomnu:%s",++i,pc->roomnu,pr->roomnu);
fprintf(fp,"roomnu cleaner phonenu type max area price clientNO\n");
fprintf(fp,"%-6s %-16s %-12s %-4s %-3d %-6.1f %-6.1f %-2d\n",pr->roomnu,pr->cleaner,pr->phonenu,pr->type,pr->maximum,pr->area,pr->unit_price,pr->currentclient);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",pc->roomnu,pc->identity_card,pc->name,pc->sex,pc->date,pc->collect,pc->time,pc->cost,pc->fee);
/*完成........1.....*/
}
pc=pc->next;
}
pr=pr->next;
}
/*這個要全表搜索,搜索一次全表過掉一個客戶*/
pr=head_room;
while(pr)
{pc=pr->head;
while(pc)
{
if(pc->next)
{tpc=pc->next;
while(tpc)
{if(0==strcmp(pc->identity_card,tpc->identity_card) && 0==strcmp(pc->date,tpc->date) )
{fprintf(fp,"Error %d:the same client:%s lived in our hotel in the same day:%s\n",++i,pc->identity_card,pc->date);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n",pc->roomnu,pc->identity_card,pc->name,pc->sex,pc->date,pc->collect,pc->time,pc->cost,pc->fee);
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",tpc->roomnu,tpc->identity_card,tpc->name,tpc->sex,tpc->date,tpc->collect,tpc->time,tpc->cost,tpc->fee);
}/*完成........3.....*/
if(0==strcmp(pc->identity_card,tpc->identity_card) && (strcmp(pc->name,tpc->name)||strcmp(pc->sex,tpc->sex)) )
{fprintf(fp,"Error %d:the same client:%s have the different name or sex in our hotel.\n",++i,pc->identity_card);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n",pc->roomnu,pc->identity_card,pc->name,pc->sex,pc->date,pc->collect,pc->time,pc->cost,pc->fee);
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",tpc->roomnu,tpc->identity_card,tpc->name,tpc->sex,tpc->date,tpc->collect,tpc->time,tpc->cost,tpc->fee);
}/*完成........4.....*/
tpc=tpc->next;
}/*while(tpc) exit */
/*當前房間比較結束,進入下一個房間*/
tpr=pr->next;
while(tpr)
{tpc=tpr->head;
while(tpc)
{if(0==strcmp(pc->identity_card,tpc->identity_card) && 0==strcmp(pc->date,tpc->date) )
{fprintf(fp,"Error %d:the same client:%s lived in our hotel in the same day:%s\n",++i,pc->identity_card,pc->date);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n",pc->roomnu,pc->identity_card,pc->name,pc->sex,pc->date,pc->collect,pc->time,pc->cost,pc->fee);
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",tpc->roomnu,tpc->identity_card,tpc->name,tpc->sex,tpc->date,tpc->collect,tpc->time,tpc->cost,tpc->fee);
}/*完成........3.....*/
if(0==strcmp(pc->identity_card,tpc->identity_card) && (strcmp(pc->name,tpc->name)||strcmp(pc->sex,tpc->sex)) )
{fprintf(fp,"Error %d:the same client:%s have the different name or sex in our hotel.\n",++i,pc->identity_card);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n",pc->roomnu,pc->identity_card,pc->name,pc->sex,pc->date,pc->collect,pc->time,pc->cost,pc->fee);
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",tpc->roomnu,tpc->identity_card,tpc->name,tpc->sex,tpc->date,tpc->collect,tpc->time,tpc->cost,tpc->fee);
}/*完成........4.....*/
tpc=tpc->next;
}/*while(tpc) exit */
tpr=tpr->next;
}/*while(tpr) exit */
}
else/*當前客戶下一節點為空的情況搜索*/
{tpr=pr->next;
while(tpr)
{tpc=tpr->head;
while(tpc)
{if(0==strcmp(pc->identity_card,tpc->identity_card) && 0==strcmp(pc->date,tpc->date) )
{fprintf(fp,"Error %d:the same client:%s lived in our hotel in the same day:%s\n",++i,pc->identity_card,pc->date);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n",pc->roomnu,pc->identity_card,pc->name,pc->sex,pc->date,pc->collect,pc->time,pc->cost,pc->fee);
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",tpc->roomnu,tpc->identity_card,tpc->name,tpc->sex,tpc->date,tpc->collect,tpc->time,tpc->cost,tpc->fee);
}/*完成........3.....*/
if(0==strcmp(pc->identity_card,tpc->identity_card) && (strcmp(pc->name,tpc->name)||strcmp(pc->sex,tpc->sex)) )
{fprintf(fp,"Error %d:the same client:%s have the different name or sex in our hotel.\n",++i,pc->identity_card);
fprintf(fp,"roomnu identity_card name sex date clt time cost fee\n");
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n",pc->roomnu,pc->identity_card,pc->name,pc->sex,pc->date,pc->collect,pc->time,pc->cost,pc->fee);
fprintf(fp,"%-6s %-18s %-15s %-3s %-8s %-3s %-4.1f %-5.1f %-5.1f\n\n",tpc->roomnu,tpc->identity_card,tpc->name,tpc->sex,tpc->date,tpc->collect,tpc->time,tpc->cost,tpc->fee);
}/*完成........4.....*/
tpc=tpc->next;
}/*while(tpc) exit */
tpr=tpr->next;
}/*while(tpr) exit */
}
pc=pc->next;/*搜索一次全表過掉一個客戶*/
}/*while(pc) exit */
pr=pr->next;
}/*while(pr) exit */
printf("Maintain NO. %d\n",++count);
fclose(fp);
return 1;
}
int ToDate(char *date,int year,int month,int day)/*將年月日轉換為字元串*/
{int i,j;
char temp[9];
for(i=3;i>-1;i--)
{j=year%10;
temp[i]=j+'0';
year=year/10;
}
for(i=1;i>-1;i--)
{j=month%10;
temp[4+i]=j+'0';
month=month/10;
}
for(i=1;i>-1;i--)
{j=day%10;
temp[6+i]=j+'0';
day=day/10;
}
temp[8]=0;
strcpy(date,temp);
return 1;
}
int Account(struct room *head_room)
{struct room *pr;
struct client *pc;
char temp[20],date[9],name[6];
float cost,fee;
int time,year,month,day;
int flag=1;
clr();
if(NULL==head_room) {printf("head_room=0\n");getch();clr();return 0;}
printf("Please input CLIENT ID(18bytes)!\n");/*mode=1表示根據身份證號查找特定客戶*/
scanf("%s",temp);
while(strlen(temp)!=18)
{printf("Error:the client(ID=%s) is not 18 bytes!",temp);
printf("Please check and input CLIENT ID(18bytes),again!\n");/*mode=1表示根據身份證號查找特定客戶*/
scanf("%s",temp);
}
/*查找客戶*/
pr=head_room;
flag=1;
while(flag&&pr)
{pc=pr->head;
while(flag&&pc)
{if( !strcmp(pc->identity_card,temp)&&!pc->time)
{printf("roomnu identity_card name sex date clt time cost fee\n");
PrintClient(pc);
flag=0;
}
if(flag) pc=pc->next;
}
pr=pr->next;
}
if(NULL==pc) {printf("Error:the client(ID=%s) does not exist in out hotel!\n",temp);getch();clr();return 0;}
/*獲取日期*/
year =GetTime(0,1);
month=GetTime(0,2);
day =GetTime(0,3);
ToDate(date,year,month,day);
time=CountDays(pc->date,date);
cost=time*pr->unit_price;
printf("The client ID=%s who have lived %d days should pay %6.1f $!\n",temp,time,cost);
printf("Please input how much you get from him and your name!\n");
printf("The money is:");
scanf("%f",&fee);
printf("Your name(collect) is:");
scanf("%s",name);
while(strlen(name)>5)
{printf("Error:the name=%s is longer than 5 bytes!",name);
printf("Please check and input ,again!\n");/*mode=1表示根據身份證號查找特定客戶*/
scanf("%s",name);
}
pc->fee=fee;
pc->cost=cost;
pc->time=time;
strcpy(pc->collect,name);
printf("Account end! Thank you!\n");
return 1;
}
Ⅳ 請高手幫忙用C語言做一個酒店管理系統
////////////////////////////
//Hotel manager system
//Design by WongSwoon
//08.11.9
////////////////////////////
#include<stdio.h>
#include<string.h>
#include<time.h>
//////////////////////////
struct Customer{
char name[10];
int id;
int tel;
int roomnum;
struct tm time;
}Customer[5][301];
//////////////////////////
struct Room{
int price;
int num;
int remain_num;
}room[5];
///////////////////////////
void InitRoom_Customer()
{
int i,j;
room[1].price=2000;
room[1].num=room[1].remain_num=5;
room[2].price=1000;
room[2].num=room[2].remain_num=100;
room[3].price=700;
room[3].num=room[3].remain_num=300;
room[4].price=400;
room[4].num=room[4].remain_num=200;
for(i=1;i<=4;i++)
for(j=1;j<=room[i].num;j++)
{
strcpy(Customer[i][j].name,"NULL");
Customer[i][j].id=0;
Customer[i][j].tel=0;
Customer[i][j].roomnum=1000*i+j;
Customer[i][j].time.tm_mon=1;
Customer[i][j].time.tm_mday=1;
}
}
///////////////////////////////////
int Isempty(struct Customer c)
{
if(!strcmp(c.name,"NULL"))
return 1;
else
return 0;
}
//////////////////////////////////
void OrderRoom(char c)
{
int i,n;
printf("roomnumber\tname\tID\ttel-num\ttime\n");
switch (c)
{
case 'a':
{
if(room[1].remain_num==0)
printf("Rooms has all been full of\n");
for(i=1;i<=room[1].num;i++)
printf("%d\t\t%s\t%d\t%d\t%d.%d\n",Customer[1][i].roomnum,Customer[1][i].name,
Customer[1][i].id,Customer[1][i].tel,Customer[1][i].time.tm_mon,Customer[1][i].time.tm_mday);
printf("Select the roomnumber and input the information:");
scanf("%d",&n);
for(i=1;i<=room[1].num;i++)
if(Customer[1][i].roomnum==n&&Isempty(Customer[1][i]))
break;
scanf("%s%d%d%d.%d",Customer[1][i].name,&Customer[1][i].id,
&Customer[1][i].tel,&Customer[1][i].time.tm_mon,&Customer[1][i].time.tm_mday);
room[1].remain_num--;
}break;
case 'b':
{
if(room[2].remain_num==0)
printf("Rooms has all been full of\n");
for(i=1;i<=room[2].num;i++)
printf("%d\t\t%s\t%d\t%d\t%d.%d\n",Customer[2][i].roomnum,Customer[2][i].name,
Customer[2][i].id,Customer[2][i].tel,Customer[2][i].time.tm_mon,Customer[2][i].time.tm_mday);
printf("Select the roomnumber and input the information:");
scanf("%d",&n);
for(i=1;i<=room[2].num;i++)
if(Customer[2][i].roomnum==n&&Isempty(Customer[2][i]))
break;
scanf("%s%d%d%d.%d",Customer[2][i].name,&Customer[2][i].id,
&Customer[2][i].tel,&Customer[2][i].time.tm_mon,&Customer[2][i].time.tm_mday);
room[2].remain_num--;
}break;
case 'c':
{
if(room[3].remain_num==0)
printf("Rooms has all been full of\n");
for(i=1;i<=room[3].num;i++)
printf("%d\t\t%s\t%d\t%d\t%d.%d\n",Customer[3][i].roomnum,Customer[3][i].name,
Customer[3][i].id,Customer[3][i].tel,Customer[3][i].time.tm_mon,Customer[3][i].time.tm_mday);
printf("Select the roomnumber and input the information:");
scanf("%d",&n);
for(i=1;i<=room[3].num;i++)
if(Customer[3][i].roomnum==n&&Isempty(Customer[3][i]))
break;
scanf("%s%d%d%d.%d",Customer[3][i].name,&Customer[3][i].id,
&Customer[3][i].tel,&Customer[3][i].time.tm_mon,&Customer[3][i].time.tm_mday);
room[3].remain_num--;
}break;
case 'd':
{
if(room[4].remain_num==0)
printf("Rooms has been full of\n");
for(i=1;i<=room[4].num;i++)
printf("%d\t\t%s\t%d\t%d\t%d.%d\n",Customer[4][i].roomnum,Customer[4][i].name,
Customer[4][i].id,Customer[4][i].tel,Customer[4][i].time.tm_mon,Customer[4][i].time.tm_mday);
printf("Select the roomnumber and input the information:");
scanf("%d",&n);
for(i=1;i<=room[4].num;i++)
if(Customer[4][i].roomnum==n&&Isempty(Customer[4][i]))
break;
scanf("%s%d%d%d.%d",Customer[4][i].name,&Customer[4][i].id,
&Customer[4][i].tel,&Customer[4][i].time.tm_mon,&Customer[4][i].time.tm_mday);
room[4].remain_num--;
}break;
}
}
//////////////////////////
void FindCustomer()
{
char c;
int i,j,flag;
flag=0;
printf("enter the customer's name\n");
scanf("%s",&c);
for(i=4;i>=1;i--)
{
for(j=1;j<=room[i].num;j++)
if(!strcmp(Customer[i][j].name,&c))
{
flag=1;
break;
}
if(flag)
break;
}
if(i==0)
printf("This gay is not found!\n");
else
{
printf("The Customer's info\n");
printf("roomnumber\tname\tID\ttel-num\ttime\n");
printf("%d\t\t%s\t%d\t%d\t%d.%d\n",Customer[i][j].roomnum,
Customer[i][j].name,Customer[i][j].id,Customer[i][j].tel,
Customer[i][j].time.tm_mon,Customer[i][j].time.tm_mday);
}
}
///////////////////////////////////
struct Customer * Find_With_RoomKey(int n)
{
/* int i,j,flag;
flag=0;
for(i=4;i>=1;i--)
{
for(j=1;j<=room[i].num;j++)
if(Customer[i][j].roomnum==n)
{
flag=1;
break;
}
if(flag)
break;
}
return &Customer[i][j];*/
return &Customer[n/1000][n%1000];//Hash method better!
}
//////////////////////////////////
long Checkout()
{
struct tm nowtime;
long sum,s_m,s_d;
int n;
printf("Input nowtime\n");
scanf("%d.%d",&nowtime.tm_mon,&nowtime.tm_mday);
printf("Enter the roomnumber\n");
scanf("%d",&n);
Find_With_RoomKey(n);
if(nowtime.tm_mday>Find_With_RoomKey(n)->time.tm_mday)
{
s_d=nowtime.tm_mday-Find_With_RoomKey(n)->time.tm_mday;
s_m=nowtime.tm_mon-Find_With_RoomKey(n)->time.tm_mon;
}
else
{
s_d=nowtime.tm_mday-Find_With_RoomKey(n)->time.tm_mday+31;
s_m=nowtime.tm_mon-Find_With_RoomKey(n)->time.tm_mon-1;
}
printf("The Room-%d Customer's info\n",Find_With_RoomKey(n)->roomnum);
printf("%d\t\t%s\t%d\t%d\t%d.%d\n",Find_With_RoomKey(n)->roomnum,
Find_With_RoomKey(n)->name,Find_With_RoomKey(n)->id,Find_With_RoomKey(n)->tel,
Find_With_RoomKey(n)->time.tm_mon,Find_With_RoomKey(n)->time.tm_mday);
sum=room[Find_With_RoomKey(n)->roomnum/1000].price*(s_m*31+s_d-2);
room[Find_With_RoomKey(n)->roomnum/1000].remain_num++;
strcpy(Find_With_RoomKey(n)->name,"NULL");
Find_With_RoomKey(n)->id=0;
Find_With_RoomKey(n)->roomnum=0;
Find_With_RoomKey(n)->tel=0;
Find_With_RoomKey(n)->time.tm_mon=1;
Find_With_RoomKey(n)->time.tm_mday=1;
return sum;
}
////////////////////////////////////////////
void Evaluate()
{
float rate;
rate=(float)(1.0-(float)( room[1].remain_num+room[2].remain_num+room[3].remain_num+room[4].remain_num)/
(room[1].num + room[2].num + room[3].num + room[4].num) );
//printf("%f",rate);
if( rate>0.8)
printf("★★★ Perfect\n");
else if(rate>0.6)
printf("★★☆ Good\n");
else
printf("★☆☆ Bad\n");
}
///////////////////////////////
void InitCmd()
{
int select;
printf("\t---------賓館管理系統v1.0 A Hotel Managerment System-----------\n");
printf("\t\t訂房-1\t查詢顧客-2\t退房-3\t每日評估-4\n");
scanf("%d",&select);
switch(select)
{
char ch;
case 1:
printf("總統套房 a \n");
printf("豪華間 b \n");
printf("標准雙人間 c \n");
printf("標准單人間 d \n");
printf("請選擇房間類型 \n");
getchar();
scanf("%c",&ch);
OrderRoom(ch);
break;
case 2:
FindCustomer();
break;
case 3:
printf("The total cash is %ld YuanRMB\n",Checkout());
printf("Checkout the room successfully!\n");
break;
case 4:
Evaluate();
}
}
//////////////////////////////
int main()
{
InitRoom_Customer();
while(1)
InitCmd();
}
Ⅵ 幫忙寫一個c語言課程設計—— 酒店管理系統
C語言程序設計題目:學生信息管理系統設計 求救: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];
Room r[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;
}
}
}
Ⅷ C語言課程設計 酒店管理程序
沒有時間寫,只有一點,朋友給的!
酒店管理
#include<stdio.h>
void xx();
void search();
main()
{ int f;
printf(" ▲***********************▲\n");
printf(" △ 歡迎來到XXX飯店△\n");
printf(" ▲************************▲\n");
printf("1.進入. 2退出.\n");
scanf("%d",&f);
if(f==1)
search();
else
printf("輸入錯誤");
}
void search()
{
int d[15],g[3],a,b,c,x,y,h;
printf("請選擇您需要的號碼:\n1.預定房間\n2.退定房間\n");
scanf("%d",&a);
if(a>3 || a<1)
{printf("您輸入有誤請您重試!\n");
}
else switch(a)
{ case 1:
{ printf("請您輸入您的身份證號碼\n");
scanf("%d",&d[15]);
printf("您已登陸成功^-^\n");
printf("請您選擇退定種類:\n");
printf("1.單人間/夜150元\n2.雙人間/夜200元\n3.標准間/夜300元\n4.總統套房/夜600元\n");
scanf("%d",&b);
switch(b)
{ case 1:printf("請輸入預定天數\n");
scanf("%d",&x);
printf("請預交款為%d元\n",x*150);
printf("1.確定 2.返回");
scanf("%d",&h);
printf("您已預定成功★房間號碼為202.\n");break;
case 2:printf("請輸入預定天數\n");
scanf("%d",&x);
printf("請預交款為%d元\n",x*200);
printf("1.確定 2.返回");
scanf("%d",&h);
printf("您已預定成功★房間號碼為305.\n");break;
case 3:printf("請輸入預定天數\n");
scanf("%d",&x);
printf("請預交款為%d元\n",x*300);
printf("1.確定 2.返回");
scanf("%d",&h);
printf("您已預定成功★房間號碼為208.\n");break;
case 4:printf("請輸入預定天數\n");
scanf("%d",&x);
printf("請預交款為%d元\n",x*600);
printf("1.確定 2.返回");
scanf("%d",&h);
printf("您已預定成功★房間號碼為306.\n");break;
default :printf("您的輸入有錯請您重試");
}
}break;
case 2:
{printf("請您輸入您的身份證號碼\n");
scanf("%d",&d[15]);
printf("您已登陸成功^-^\n");
printf("請您選擇退訂服務種類:\n");
printf("1.單人間/夜150元\n2.雙人間/夜200元\n3.標准間/夜300元\n4.總統套房/夜600元\n");
scanf("%d",&c);
switch(c)
{case 1:printf("請您輸入要退定的房間號碼\n");
scanf("%d",&g[3]);
printf("請您輸入要退訂的天數\n");
scanf("%d",&y);
printf("我們將退您%d元\n",y*150);
printf("您退定成功: 謝謝您的光臨 !\n");break;
case 2:printf("請您輸入要退定的房間號碼\n");
scanf("%d",&g[3]);
printf("請您輸入要退訂的天數\n");
scanf("%d",&y);
printf("我們將退您%d元\n",y*200);
printf("您退定成功.謝謝您的光臨 !");break;
case 3:printf("請您輸入要退定的房間號碼\n");
scanf("%d",&g[3]);
printf("請您輸入要退訂的天數\n");
scanf("%d",&y);
printf("我們將退您%d元\n",y*300);
printf("您退定成功:謝謝您的光臨 !\n");break;
case 4:printf("請您輸入要退定的房間號碼\n");
scanf("%d",&g[3]);
printf("請您輸入要退訂的天數\n");
scanf("%d",&y);
printf("我們將退您%d元\n",y*600);
printf("您退定成功:謝謝您的光臨 !\n");break;
default:printf("您的輸入有錯請您重試");}
}break;}
{
int n;
printf("謝謝光顧\n是否要再預定? 1.是2.否");
scanf("%d",&n);
if(n==1)
search();
else
printf("再見");
}
}