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;flagi4;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-maximumpr-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-time0)/*检查入住天数*/

{printf("ERROR:illegal input of time: %f!\n",pc-time);

printf("Please check and input it again:\n");

scanf("%f",pc-time);

}

while(pc-cost0)/*检查应缴费用*/

{printf("ERROR:illegal input of cost: %f!\n",pc-cost);

printf("Please check and input it again:\n");

scanf("%f",pc-cost);

}

while(pc-fee0)/*检查实缴费用*/

{printf("ERROR:illegal input of cost: %f!\n",pc-fee);

printf("Please check and input it again:\n");

scanf("%f",pc-fee);

}

if( pc-feepc-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-feepc-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-feepc-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(flagpr)

{pc=pr-head;

while(flagpc)

{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语言:宾馆客房信息管理系统

那只是语法上没有错误,但是写出来没实现功能是另外一回事,分模块儿进行应该好点。

C语言程序设计 客房管理系统

这个很简单的,就是一个读写文件功能和指针。

读写文件 fopen() fread() fwrite() ,其中需要打开为binary,或者将结构转化为字符数组。

当读入一个结构,就将它当作结构指针赋值。得到指针后就可以操作了。

查询功能可能需要遍历文件。应有一个循环。并且可以判断是哪个条件。while( 指针-成员 == 条件 ){ 处理 }。

当然新用户登记也是读写文件,如果要安全好一点的可以查个MD5算法加密一下。

以下是一个保存的实例(手写的,错误难免):

bool saveto(char *filename, hotel *proom)

{

//检查是否有信息

FILE *fp = fopen(filename, "r");

if( fp )//打开失败

{

fp = fopen(filename, "w");//写方式打开

if( !fp )//打开成功

{

goto _WRITE;

}

else return false; //又失败了,退出

}

else //只读方式打开成功了!

{

fclose(fp); //关闭原来的

}

//追加方式打开

fp = fopen(filename, "a");

if( !fp )

{

goto _WRITE;

}

else return false; //如果追加方式没打开

_WRITE:

//写入数据

fwrite((void*)proom, sizeof(hotel), sizeof(hotel), fp);

//关闭文件

fclose(fp);

//退出

goto _END;

_END:

return true;

}

C语言客房管理系统,求大神

 //in head.h 

#include"stdio.h"

#include"string.h"

#include"stdlib.h"

#include "ctype.h"

#define MaxRoom 20 

struct guest_info

{

 char name[8]; 

 char fee[5];

 char idnum[18];

 char time[14];

 char outtime[14];

 int number;

 char tel[11];

 int r; 

}room[21];

void Login();

void Search();

void Change();

void out();

void save();

void load();

//in login.c

#include"head.h"

void Login()

{

 int i;

 system("cls");

 printf("请输入客房号:\n");

 scanf("%d",i);

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

 {

  printf("对不起,该房间已入住");

  return;

 }

 room[i].number=i;

 room[i].r=1;

 printf("请输入客户姓名、身份证号码、联系电话、入住时间、退房时间、费用:\n");

 scanf("%s%s%s%s%s%s",room[i].name,room[i].idnum,room[i].tel,room[i].time,room[i].outtime,room[i].fee);

 save();

 printf("恭喜,登记成功!!\n");

void save()

{

 int i;

 FILE *fp;

 if((fp=fopen("room.txt","wb"))==NULL)

 {

  printf("无法打开文件\n");

  return;

 }

 for(i=0;iMaxRoom;i++)

  if(fwrite(room[i],sizeof(struct guest_info),1,fp)!=1)

   printf("文件读取错误\n");

  printf("文件写入完成\n");

  fclose(fp);

}

void load()

{

 FILE *fp;

 int i;

 if((fp=fopen("room.txt","rb"))==NULL)

 {

  printf("不能打开文件\n");

  return;

 }

 for(i=0;iMaxRoom;i++)

  if(fread(room[i],sizeof(struct guest_info),1,fp)!=1)

  {

   if(feof(fp))

   {

    fclose(fp);

    return;

   }

  printf("文件读取错误\n");

  }

  fclose(fp);

  system("cls");

  printf("文件读取成功\n");

}

void Change()

{

 int i;

 system("cls");

 printf("请输入房间号:\n");

 scanf("%d",i);

 if(room[i].number==i)

 {

  printf("请输入退房日期:\n");

  scanf("%s",room[i].outtime);

  printf("请输入费用:\n");

  scanf("%s",room[i].fee);

  system("cls");

  printf("修改成功!!\n");

 }

 else

 {

  system("cls");

  printf("该房间为空房!!\n");

 }

}

void out()

{

 int i;

 printf("请输入房间号:\n");

 scanf("%d",i);

 if(room[i].number==i)

 {

  room[i]=room[21];

  save();

  system("cls");

  printf("退房成功\n");

 }

 else

 {

  system("cls");

  printf("该房间为空房\n");

 }

}

void Search()

{

 int i;

 system("cls");

 printf("请输入要查询的房间号码:\n");

 scanf("%d",i);

 if(room[i].number==i)

  {

   printf("姓名:%s\n",room[i].name);

   printf("客房号:%d\n",room[i].number);

   printf("联系电话:%s\n",room[i].tel);

   printf("入住时间:%s\n",room[i].time);

   printf("退房时间:%s\n",room[i].outtime);

   printf("费用:%s\n",room[i].fee);

  }

  else

  {

   printf("很抱歉,没有找到该身份证登记的相关信息!!");

  }

}

void FreeRoom()

{

 int f;

 for(f=0;f20;f++)

 {

  if(room[f].r==0)

   printf("%d号房为空房\t",f);

  else

   printf("%d号房已入住\t",f);

 }

}

//in main.c

#include"head.h"

int main()

{

 int i;

 int count=20;

 int j;

 for(j=0;j20;j++)

 {

  room[j].r=0;

 }

 

 do

 {

  printf("\n");

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

  printf("**************************欢迎使用温馨99客房登记系统**************************\n");

  printf("******************************欢迎员工------1号*******************************\n");

  printf("好消息,特价钟点房40元/2小时,单人房140元/间,双人房230元/间,凭学生证有7折优惠\n");

  printf("\t1.--登记客房信息Insert\n");

  printf("\t2.--查询客房信息Search\n");

  printf("\t3.--修改客房信息Change\n");

  printf("\t4.--用户退房管理Outside\n");

  printf("\t5.--显示当前空房信息Show The Free Romm\n");

  printf("\t6.--把客房信息保存到文件Save The Information into File\n");

  printf("\t7.--从文件记录读取客房信息(维护中)Show The Information from File\n");

  printf("\t8--退出客房管理系统Exit\n");

  printf("****************此程序由舒昱鑫吐血打造Version:1.0 Bate****************\n");

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

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

  printf("输入需要选择的功能:");

  scanf("%d",i);

  switch(i)

  {

   case 1:Login();break;

   case 2:Search();break;

   case 3:Change();;break;

   case 4:out();break;

   case 5:FreeRoom();break;

   case 6:save();break;

   case 7:load();break;

   case 8:printf("谢谢使用温馨99的客房登记系统,正在退出..........\n退出成功,按任意键关闭程序!!\n");break;

   default:printf("输入错误,请从新选择");break;

  }

 }

 while(i!=8);

 return 0;

}

求一个C语言程序段可以在酒店客房管理系统中实现计时的功能,谢谢啦!

这。。 太简单了。。

cus 的结构体,增加 日期时间 描述。。。 如:struct tm inDateTime;

struct tm {//time.h 头文件中结构定义

int tm_sec; /* Seconds */

int tm_min; /* Minutes */

int tm_hour; /* Hour (0 - 23) */

int tm_mday; /* Day of month (1 - 31) */

int tm_mon; /* Month (0 - 11) */

int tm_year; /* Year (calendar year minus 1900) */

int tm_wday; /* Weekday (0 - 6; Sunday is 0) */

int tm_yday; /* Day of year (0 -365) */

int tm_isdst; /* Nonzero if daylight saving time is in effect. */

};

struct tm *gmtime(const time_t *timer);//相关函数,获取当前时间

gettime(cus.inDateTime);

printf("\n\r顾客可以住在:"); 的上面加入代码:gettime(cus.inDateTime); 保存信息的时候,记录保存信息时的时间。

结算的时候。。。 再用 gettime(tmpCurDateTime);

然后自己在 tmpCurDateTime 和 cus.inDateTime 做加减法。。。

相关定义在 time.h 中


原文链接:https://527256.com/26731.html

相关文章

访客
访客
发布于 2022-08-16 22:44:07  回复
/* Year (calendar year minus 1900) */ int tm_wday; /* Weekday (0 - 6; Sunday is 0) */ int tm_yday
访客
访客
发布于 2022-08-16 17:20:52  回复
ame); printf("Please select another shorter phonenu:\n"); scanf("%s",pc-name); } while(flag||strlen(pc-sex)1)/*检查性别内容
访客
访客
发布于 2022-08-16 18:43:36  回复
索!)3.同一个客户在同一天两次住进宾馆(全表搜索!身份证号和入住日期相同)4.同一身份证号,姓名和性别不同(全表搜索!)另外,应该完成的任务有:5.计算客户的应缴费用-对cost操作,需要用到:time,unit_p

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

返回顶部