|
|
@ -0,0 +1,191 @@
|
|
|
|
|
|
|
|
#define _CRT_SECURE_NO_WARNINGS
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <string.h> //在使用中要用到的字符串都包含在本文件中
|
|
|
|
|
|
|
|
#include <stdlib.h> //exit()函数就包含在此文件中
|
|
|
|
|
|
|
|
#include <conio.h>
|
|
|
|
|
|
|
|
#define isPrime(year) ((year%4==0&&year%100!=0)||(year%400==0))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int z[100]={0};
|
|
|
|
|
|
|
|
int s,j;
|
|
|
|
|
|
|
|
FILE *fp;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void check_in(); //声明登记入住函数
|
|
|
|
|
|
|
|
void availability(); //声明查询房间入住情况函数
|
|
|
|
|
|
|
|
void fate_days(); //声明查询日用住宿的费用
|
|
|
|
|
|
|
|
void fate_hours(); //声明查询时用住宿的费用
|
|
|
|
|
|
|
|
void check_out_days(); //声明结日用住宿的费用
|
|
|
|
|
|
|
|
void check_out_hours(); //声明结时用住宿的费用
|
|
|
|
|
|
|
|
void modificate(); //声明修改信息函数
|
|
|
|
|
|
|
|
void modificate_person(); //声明修改信息函数中的修改客户信息
|
|
|
|
|
|
|
|
void modificate_accommodation(); //声明修改信息函数中的修改住宿信息
|
|
|
|
|
|
|
|
void save(); //声明保存函数
|
|
|
|
|
|
|
|
void menu(); //声明菜单函数
|
|
|
|
|
|
|
|
void days(); //声明入住类型为天数函数
|
|
|
|
|
|
|
|
void hours(); //声明入住类型为小时函数
|
|
|
|
|
|
|
|
int date1Diff(); //声明计算天数差函数
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct date1
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int year;
|
|
|
|
|
|
|
|
int month;
|
|
|
|
|
|
|
|
int day;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Date
|
|
|
|
|
|
|
|
{int year;
|
|
|
|
|
|
|
|
int month;
|
|
|
|
|
|
|
|
int day;
|
|
|
|
|
|
|
|
int hour;
|
|
|
|
|
|
|
|
int minute;
|
|
|
|
|
|
|
|
}date; //定义日期变量
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct room
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int room_ID; //房间号
|
|
|
|
|
|
|
|
int kind; //房间种类(包含单人间,双人间,三人间,VIP套房)
|
|
|
|
|
|
|
|
char name[20]; //客户姓名
|
|
|
|
|
|
|
|
int age; //客户年龄
|
|
|
|
|
|
|
|
int sex; //客户性别
|
|
|
|
|
|
|
|
char ID_card[20]; //客户身份证号
|
|
|
|
|
|
|
|
int day_money; //按日收费价格
|
|
|
|
|
|
|
|
int hour_money; //按小时收费价格
|
|
|
|
|
|
|
|
int count; //房间数量
|
|
|
|
|
|
|
|
struct Date date;
|
|
|
|
|
|
|
|
}room[100];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
menu(); //把主菜单用函数来实现
|
|
|
|
|
|
|
|
save();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void menu()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int n;
|
|
|
|
|
|
|
|
do
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
printf(" \t ******************欢迎入住酒店***************** \n");
|
|
|
|
|
|
|
|
printf("\n *********************菜单********************");
|
|
|
|
|
|
|
|
printf("\n******* 1.登记入住 \t *******\n");
|
|
|
|
|
|
|
|
printf("******* 2.查询房间入住情况 \t *******\n");
|
|
|
|
|
|
|
|
printf("******* 3.查询当前费用(日用) \t *******\n");
|
|
|
|
|
|
|
|
printf("******* 4.查询当前费用(时用) \t *******\n");
|
|
|
|
|
|
|
|
printf("******* 5.结账当前费用(日用) \t *******\n");
|
|
|
|
|
|
|
|
printf("******* 6.结账当前费用(时用) \t *******\n");
|
|
|
|
|
|
|
|
printf("******* 7.退出 \t *******");
|
|
|
|
|
|
|
|
printf(" *********************菜单********************\n"); //输出菜单界面,让操作员能够方便的选择所需要进行的操作
|
|
|
|
|
|
|
|
printf("\n接下来的操作中,如果您的信息输入错误,请在下一步时输入0,则返回菜单,重新选择");
|
|
|
|
|
|
|
|
printf("\n请输入数字来选择操作:");
|
|
|
|
|
|
|
|
scanf("%d",&n);
|
|
|
|
|
|
|
|
while(n<1||n>7)
|
|
|
|
|
|
|
|
{printf(" *********************您输入的数字有误,请重新输入。********************\n");
|
|
|
|
|
|
|
|
scanf("%d",&n);}
|
|
|
|
|
|
|
|
switch(n)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case 1:check_in();break; //调用登记入住函数
|
|
|
|
|
|
|
|
case 2:availability();break; //调用查询房间的入住情况函数
|
|
|
|
|
|
|
|
case 3:fate_days();break; //调用查询当前日用费用函数
|
|
|
|
|
|
|
|
case 4:fate_hours();break; //调用查询当前时用费用函数
|
|
|
|
|
|
|
|
case 5:check_out_days();break; //调用结账日用费用函数
|
|
|
|
|
|
|
|
case 6:check_out_hours();break; //调用结账当前时用费用函数
|
|
|
|
|
|
|
|
case 7:exit(0); //退出
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}while(n!=7);
|
|
|
|
|
|
|
|
scanf("%d",&n);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void check_in() // 登记函数
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int op,way,po,i,num;
|
|
|
|
|
|
|
|
printf("请输入需要的房间数量:");
|
|
|
|
|
|
|
|
scanf("%d", &num); while(num<0||num>100)
|
|
|
|
|
|
|
|
{printf(" *********************您输入的数字有误,请重新输入。********************\n");
|
|
|
|
|
|
|
|
scanf("%d",&num);}
|
|
|
|
|
|
|
|
if(num==0) menu();
|
|
|
|
|
|
|
|
for (i=1;i<=num;++i) {
|
|
|
|
|
|
|
|
printf("请输入登记相关信息:\n");
|
|
|
|
|
|
|
|
printf("\n房间%d房号:(1号到100号之间)",i);
|
|
|
|
|
|
|
|
scanf("%d", &j);if(j==0) menu();
|
|
|
|
|
|
|
|
room[j].room_ID = j;
|
|
|
|
|
|
|
|
printf("\n请输入年龄:");
|
|
|
|
|
|
|
|
scanf("%d", &room[j].age);if(room[j].age==0) menu();
|
|
|
|
|
|
|
|
while (j<0||j>100)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("您的输入有误,请重新输入");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n请选择住宿时间类型:(1表示按天计费;2表示按小时计费)\n\t *****注意:如果您所居住时间包括了晚上,请您选择按天计费*****");
|
|
|
|
|
|
|
|
scanf("%d", &way);if(way==0) menu();
|
|
|
|
|
|
|
|
printf("\n入住时间为(年):");
|
|
|
|
|
|
|
|
scanf("%d", &room[j].date.year);if(room[j].date.year==0) menu();
|
|
|
|
|
|
|
|
printf("\n入住时间为(月):");
|
|
|
|
|
|
|
|
scanf("%d", &room[j].date.month);if(room[j].date.month==0) menu();
|
|
|
|
|
|
|
|
printf("\n入住时间为(日):");
|
|
|
|
|
|
|
|
scanf("%d", &room[j].date.day);if(room[j].date.day==0) menu();
|
|
|
|
|
|
|
|
if (way == 1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n房间种类:[1代表单人间(200元/天);2代表双人间(390元/天);3代表三人间(475元/天);4代表VIP套房(650元/天)]");
|
|
|
|
|
|
|
|
scanf("%d", &op);if(op==0) menu();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (way == 2)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("\n房间种类:[1代表单人间(10元/小时);2代表双人间(19元/小时);3代表三人间(27元/小时);4代表VIP套房(45元/小时)]");
|
|
|
|
|
|
|
|
scanf("%d", &po);if(po==0) menu();
|
|
|
|
|
|
|
|
printf("\n入住时间为(小时):");
|
|
|
|
|
|
|
|
scanf("%d", &room[j].date.hour);if(room[j].date.hour==0) menu();
|
|
|
|
|
|
|
|
printf("\n入住时间为(分钟):");
|
|
|
|
|
|
|
|
scanf("%d", &room[j].date.minute);if(room[j].date.minute==0) menu();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n姓名:");
|
|
|
|
|
|
|
|
scanf("%s", &room[j].name);if(room[j].name==0) menu();
|
|
|
|
|
|
|
|
printf("\n性别(其中:1表示男,2表示女!):");
|
|
|
|
|
|
|
|
scanf("%d", &room[j].sex);if(room[j].sex==0) menu();
|
|
|
|
|
|
|
|
printf("\n身份证号:");
|
|
|
|
|
|
|
|
scanf("%s", &room[j].ID_card);if(room[j].ID_card==0) menu();
|
|
|
|
|
|
|
|
z[j] = 1; //标记使用的房间为1
|
|
|
|
|
|
|
|
save();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
menu();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void availability() //查询房间入住情况函数
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int g,count=0;
|
|
|
|
|
|
|
|
for(g=0;g<100;g++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(z[g]==0)
|
|
|
|
|
|
|
|
++count;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
if(z[g]==1)
|
|
|
|
|
|
|
|
printf("\n正在使用的房间号:%d",g);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n\n未使用的房间数:%d",count); //通过循环输出未使用的房间数
|
|
|
|
|
|
|
|
printf("\n\n");
|
|
|
|
|
|
|
|
printf("\n请输入需查询的房间号: "); //查询输入的房间号的信息,且输出该房间的相关信息
|
|
|
|
|
|
|
|
scanf("%d",&s);
|
|
|
|
|
|
|
|
while(s<0||s>100)
|
|
|
|
|
|
|
|
{printf(" *********************您输入的数字有误,请重新输入。********************\n");
|
|
|
|
|
|
|
|
scanf("%d",&s);}if(s==0) menu();
|
|
|
|
|
|
|
|
if(z[s]==1)
|
|
|
|
|
|
|
|
{printf("姓名:%s",room[s].name);
|
|
|
|
|
|
|
|
printf("\n性别(其中:1表示男,2表示女):%d",room[s].sex);
|
|
|
|
|
|
|
|
printf("\n年龄:%d",room[s].age);
|
|
|
|
|
|
|
|
printf("\n身份证号:%s",room[s].ID_card);
|
|
|
|
|
|
|
|
printf("\n年:%d",room[s].date.year);
|
|
|
|
|
|
|
|
printf(" 月:%d",room[s].date.month);
|
|
|
|
|
|
|
|
printf(" 日:%d",room[s].date.day);
|
|
|
|
|
|
|
|
printf("\n房间号:%d",room[s].room_ID);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
printf("该房间未被使用!");
|
|
|
|
|
|
|
|
menu();
|
|
|
|
|
|
|
|
save(); //调用保存函数
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|