| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2904 人关注过本帖
标题:C语言实习题目,自己不行了..搞不定回不了家了....
只看楼主 加入收藏
anbl4321
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2007-7-15
收藏
 问题点数:0 回复次数:37 
C语言实习题目,自己不行了..搞不定回不了家了....
哪位好心人能帮我完成这个题目啊?我真得无能为力了,学得太烂了
anbaile_0319@163.com 我的邮箱号,麻烦能帮的就帮我吧...
34
.房客管理系统
要求 系统包括新用户登记功能、统计功能、查询功能、修改功能
提示
建立如下结构体:
struct Client
{
char Name[20];
int Sex;
char ID_card[20];//居民身份证;
int year;
int month;
int date;//住店时间
};
struct Hotel
{
int Room_ID;//房间号
int Tel;
int Price:
bool Sing;//标记房间是否为空房间;
struct Client Client_list;//实现两个结构体的嵌套
}Room[NUM];
搜索更多相关主题的帖子: C语言 居民身份证 int 
2007-07-15 13:19
anbl4321
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2007-7-15
收藏
得分:0 
2007-07-15 13:34
anbl4321
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2007-7-15
收藏
得分:0 
回不了家了.....
2007-07-15 13:47
anbl4321
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2007-7-15
收藏
得分:0 
2007-07-15 20:20
岳C
Rank: 1
等 级:禁止发言
帖 子:354
专家分:0
注 册:2007-7-16
收藏
得分:0 
提示: 作者被禁止或删除 内容自动屏蔽

坚持到底
2007-07-16 02:13
mzjllh
Rank: 2
来 自:江苏扬州
等 级:论坛游民
帖 子:76
专家分:41
注 册:2007-2-8
收藏
得分:0 
我试试帮你写个吧,明天贴上来不迟吧


还是贴到这里吧,方便大家下:)
VbLIVt3Z.rar (40.13 KB)

[此贴子已经被作者于2007-7-18 21:50:06编辑过]

2007-07-16 16:45
mzjllh
Rank: 2
来 自:江苏扬州
等 级:论坛游民
帖 子:76
专家分:41
注 册:2007-2-8
收藏
得分:0 
兄弟我来迟了,不知道你回家了没,程序写好了,不知道符合要求不,贴上来大家指正指正吧。

微软编译器编译通过,运行正常。代码如下:

/*|------------------------|*/
/*|*******包含头文件*******|*/
/*|________________________|*/
#include <stdio.h>
#include <conio.h>
#include <malloc.h>
#include <ctype.h>
#include <dos.h>
#include <time.h>
#include <malloc.h>
/*|------------------------|*/
/*|******预定义标识符******|*/
/*|________________________|*/
#define SPACE ""
#define DEFAULTPATH "c:\\KFTZ.tz"
#define UP 72
#define DOWN 80
#define LEFT 75
#define RIGHT 77
#define ESC 27
#define ZERO 0
#define BLACK "0"
#define BLUE "1"
#define GREEN "2"
#define RED "4"
#define YELLOW "6"
#define WHITE "7"
#define LOAD "1"
#define SAVE "2"
#define CHECKIN "3"
#define CHECKOUT "4"
#define BOOK "5"
#define UNBOOK "6"
#define READY "7"
#define CQUERY "8"
#define MODIFY "9"
#define HQUERY "10"
#define REBUILD "11"
#define ADDHOUSE "12"
#define STATISTIC "13"
#define CLS "14"
#define MODICOLOR "15"
#define MENU "16"
#define HELP "17"
#define EXIT "18"
/*|------------------------|*/
/*|******枚举类型定义******|*/
/*|________________________|*/
enum housestatus
{EMPTY=0,BOOKED=1,CHECKEDIN=2}; /*房间状态*/
/*|------------------------|*/
/*|*******结构体定义*******|*/
/*|________________________|*/
struct Client
{
char Name[20];
char Sex[6];
char ID_card[20]; /*居民身份证*/
int year;
int month;
int day; /*住店时间*/
};
struct Hotel
{
char Room_ID[6]; /*房间号*/
char Tel[12];
unsigned Price;
enum housestatus Sing; /*标记房间是否为空房间*/
struct Client Client_list; /*实现两个结构体的嵌套*/
};
struct Rooms
{
struct Rooms *before;
struct Hotel theroom;
struct Rooms *next;
};
struct Roomp
{
struct Roomp *before;
struct Hotel *theroom;
struct Roomp *next;
};
struct Customers
{
struct Customers *before;
struct Client *thecustomer;
struct Customers *next;
};
/*|------------------------|*/
/*|********变量声明********|*/
/*|________________________|*/
char command[20];
char BGCOLOR[7]=BLACK;
char FORCOLOR[7]=WHITE;
char COLOR[3];
unsigned ROOMCNT=0;
unsigned ROOMREADY=0;
struct Rooms *ROOM=NULL;
struct Rooms *Roomtail=NULL;
char LOADPATH[50]=DEFAULTPATH;
char SAVEPATH[50]=DEFAULTPATH;
unsigned SAVED=1;
/*|------------------------|*/
/*|********函数声明********|*/
/*|________________________|*/
int year(); /*取当前系统时间的年份*/
int month(); /*取当前系统时间的月份*/
int day(); /*取当前系统时间的日期*/
void book(); /*预订房间*/
void unbook(); /*退订房间*/
void checkin(); /*开房*/
void checkout(); /*退房*/
void ready(); /*查看空房间*/
void statistic(); /*统计*/
void cquery(); /*房客查询*/
void hquery(); /*客户查询*/
void modify(); /*修改房客信息*/
void rebuild(); /*修改房间信息*/
void menu(); /*菜单*/
void dispmenu(); /*显示菜单*/
void flushstdin(); /*刷新输入缓冲区*/
void testsave(); /*当前台账是否保存*/
void addhouse(); /*新增房间*/
void load(); /*载入台账*/
void save(); /*保存台账*/
void cls(); /*清屏*/
void modicolor(); /*调整界面着色*/
void customerout(struct Hotel*); /*清除房间客人信息*/
void help(); /*显示帮助信息*/
int roomidexists(char *); /*房间号是否已存在*/
int telexists(char *); /*电话号码是否已存在*/
char *cmdtolower(char *cmd); /*命令转换为小写*/
struct Client registercustomer();/*登记房客*/
/*|------------------------|*/
/*|********函数定义********|*/
/*|________________________|*/
int year() /*取当前系统时间的年份*/
{
time_t tval;
struct tm *now;
tval=time(NULL);
now=localtime(&tval);
return now->tm_year+1900;
}
int month() /*取当前系统时间的月份*/
{
time_t tval;
struct tm *now;
tval=time(NULL);
now=localtime(&tval);
return now->tm_mon;
}
int day() /*取当前系统时间的日期*/
{
time_t tval;
struct tm *now;
tval=time(NULL);
now=localtime(&tval);
return now->tm_mday;
}
int roomidexists(char *roomid) /*房间号是否已存在*/
{
struct Rooms *HEAD=ROOM;
struct Rooms *CUSOR=HEAD;
if(CUSOR==NULL) return 0;
while(CUSOR!=NULL)
{
if(!strcmp(roomid,CUSOR->theroom.Room_ID)) return 1;
CUSOR=CUSOR->next;
}
return 0;
}
int telexists(char *tel) /*电话号码是否已存在*/
{
struct Rooms *HEAD=ROOM;
struct Rooms *CUSOR=HEAD;
if(CUSOR==NULL) return 0;
while(CUSOR!=NULL)
{
if(!strcmp(tel,CUSOR->theroom.Tel)) return 1;
CUSOR=CUSOR->next;
}
return 0;
}
void customerout(struct Hotel *r)/*清除房间客人信息*/
{
strcpy(r->Client_list.Name,"");
strcpy(r->Client_list.Sex,"");
strcpy(r->Client_list.ID_card,"");
r->Client_list.year=0;
r->Client_list.month=0;
r->Client_list.day=0;
}
struct Client registercustomer() /*登记房客*/
{
struct Client newcustomer;
printf("\t\t\t ======房客信息登记======\n");
printf("\n姓名:");
scanf("%s",newcustomer.Name);
printf("\n性别:");
scanf("%s",newcustomer.Sex);
printf("\n身份证号:");
scanf("%s",newcustomer.ID_card);
newcustomer.year=year();
newcustomer.month=month();
newcustomer.day=day();
return newcustomer;
}
void book() /*预订房间*/
{
char roomid[6]="";
struct Client customer;
struct Rooms *HEAD=ROOM;
struct Rooms *CUSOR=HEAD;
if(CUSOR==NULL)
{
printf("\n预订失败:酒店现无房间!\n");
return;
}
if(ROOMREADY==0)
{
printf("\n预订失败:酒店已无空房间!\n");
return;
}
customer=registercustomer();
while(1)
{
printf("\n预订房间号:");
scanf("%s",roomid);
cmdtolower(roomid);
if(!strcmp(roomid,"quit")) break;
HEAD=ROOM;
CUSOR=HEAD;
while(CUSOR!=NULL)
{
if(!strcmp(roomid,CUSOR->theroom.Room_ID)) break;
CUSOR=CUSOR->next;
}
if(CUSOR==NULL)
{
printf("\n预订失败:房间号不存在!\n");
continue;
}
if(CUSOR->theroom.Sing==EMPTY)
{
CUSOR->theroom.Sing=BOOKED;
CUSOR->theroom.Client_list=customer;
ROOMREADY--; /*空房间减一*/
SAVED=0;
printf("\n房间预订成功!\n");
break;
}
if(CUSOR->theroom.Sing==BOOKED)
{
printf("\n预订失败:该房间已被预订,请选择其他房间!\n");
continue;
}
if(CUSOR->theroom.Sing==CHECKEDIN)
{
printf("\n预订失败:该房间已有房客入住,请选择其他房间!\n");
continue;
}
}
}
void unbook() /*退订房间*/
{
char roomid[6]="";
char flag='x';
struct Client customer;
struct Rooms *HEAD=ROOM;
struct Rooms *CUSOR=HEAD;
if(CUSOR==NULL)
{
printf("\n退订失败:酒店现无房间!\n");
return;
}
if(ROOMREADY==ROOMCNT)
{
printf("\n预订失败:酒店目前尚无被预订房间!\n");
return;
}
while(1)
{
printf("\n退订房间号:");
scanf("%s",roomid);
cmdtolower(roomid);
if(!strcmp(roomid,"quit")) break;
HEAD=ROOM;
CUSOR=HEAD;
while(CUSOR!=NULL)
{
if(!strcmp(roomid,CUSOR->theroom.Room_ID)) break;
CUSOR=CUSOR->next;
}
if(CUSOR==NULL)
{
printf("\n退订失败:房间号不存在!\n");
continue;
}
if(CUSOR->theroom.Sing==BOOKED)
{
customer=CUSOR->theroom.Client_list;
printf("\n房间已找到,房间信息如下:\n");
printf("\t\t==============================================\n");
printf("\t\t 房间号 房间电话 房间价格 房间状态 \n");
printf("\t\t*--------------------------------------------*\n");
printf("\t\t %4s %7s %4u 已预订 \n",CUSOR->theroom.Room_ID,CUSOR->theroom.Tel,CUSOR->theroom.Price);
printf("\t\t==============================================\n");
printf("\n房间预订者信息如下:\n");
printf("\t\t==============================================\n");
printf("\t\t 姓 名 性 别 身份证号 登记时间 \n");
printf("\t\t*--------------------------------------------*\n");
printf("\t\t %6s %2s %18s %d/%d/%d\n",customer.Name,customer.Sex,customer.ID_card,customer.year,customer.month,customer.day);
printf("\t\t==============================================\n");
printf("\n确定退订该房间吗?(Y/N)\n");
while(!kbhit());
while(flag!='y'&&flag!='Y'&&flag!='n'&&flag!='N')
{
flag=getch();
flag=tolower(flag);
switch(flag)
{
case 'y':{CUSOR->theroom.Sing=EMPTY;customerout(&(CUSOR->theroom));ROOMREADY++;SAVED=0;printf("\n房间退订成功!\n");break;}
case 'n':{printf("\n放弃退订房间!\n");break;}
default:{printf("\nPress y for yes or n for no!\n");break;}
}
}
break;
}
if(CUSOR->theroom.Sing==EMPTY)
{
printf("\n退订失败:该房间目前为空房间!\n");
continue;
}
if(CUSOR->theroom.Sing==CHECKEDIN)
{
printf("\n退订失败:该房间已有房客入住,非预订房间,如需退房请选择退房登记!\n");
continue;
}
}
}
void checkin() /*开房*/
{
char roomid[6]="";
struct Client customer;
struct Rooms *HEAD=ROOM;
struct Rooms *CUSOR=HEAD;
if(CUSOR==NULL)
{
printf("\n开房失败:酒店现无房间!\n");
return;
}
customer=registercustomer();
while(1)
{
printf("\n房间号:");
scanf("%s",roomid);
cmdtolower(roomid);
if(!strcmp(roomid,"quit")) break;
HEAD=ROOM;
CUSOR=HEAD;
while(CUSOR!=NULL)
{
if(!strcmp(roomid,CUSOR->theroom.Room_ID)) break;
CUSOR=CUSOR->next;
}
if(CUSOR==NULL)
{
printf("\n开房失败:房间号不存在!\n");
continue;
}
if(CUSOR->theroom.Sing==EMPTY)
{
CUSOR->theroom.Sing=CHECKEDIN;
CUSOR->theroom.Client_list=customer;
ROOMREADY--; /*空房间减一*/
SAVED=0;
printf("\n开房成功!\n");
break;
}
if(CUSOR->theroom.Sing==BOOKED)
{
if(strcmp(CUSOR->theroom.Client_list.Name,customer.Name))
{
printf("\n开房失败:该房间已被其他顾客预订,请选择其他房间!\n");
continue;
}
else
{
CUSOR->theroom.Sing=CHECKEDIN;
CUSOR->theroom.Client_list=customer;
printf("\n开房成功!\n");
break;
}
}
if(CUSOR->theroom.Sing==CHECKEDIN)
{
printf("\n开房失败:该房间已有房客入住,请选择其他房间!\n");
continue;
}
}
}
void checkout() /*退房*/
{
char roomid[6]="";
char flag='x';
struct Client customer;
struct Rooms *HEAD=ROOM;
struct Rooms *CUSOR=HEAD;
if(CUSOR==NULL)
{
printf("\n退房失败:酒店现无房间!\n");
return;
}
if(ROOMREADY==ROOMCNT)
{
printf("\n预房失败:酒店目前尚无有客房间!\n");
return;
}
while(1)
{
printf("\n待退房间号:");
scanf("%s",roomid);
cmdtolower(roomid);
if(!strcmp(roomid,"quit")) break;
HEAD=ROOM;
CUSOR=HEAD;
while(CUSOR!=NULL)
{
if(!strcmp(roomid,CUSOR->theroom.Room_ID)) break;
CUSOR=CUSOR->next;
}
if(CUSOR==NULL)
{
printf("\n退房失败:房间号不存在!\n");
continue;
}
if(CUSOR->theroom.Sing==CHECKEDIN)
{
customer=CUSOR->theroom.Client_list;
printf("\n房间已找到,房间信息如下:\n");
printf("\t\t==============================================\n");
printf("\t\t 房间号 房间电话 房间价格 房间状态 \n");
printf("\t\t*--------------------------------------------*\n");
printf("\t\t %4s %7s %4u 已入住 \n",CUSOR->theroom.Room_ID,CUSOR->theroom.Tel,CUSOR->theroom.Price);
printf("\t\t==============================================\n");
printf("\n房客信息如下:\n");
printf("\t\t==============================================\n");
printf("\t\t 姓 名 性 别 身份证号 登记时间 \n");
printf("\t\t*--------------------------------------------*\n");
printf("\t\t %6s %2s %18s %d/%d/%d\n",customer.Name,customer.Sex,customer.ID_card,customer.year,customer.month,customer.day);
printf("\t\t==============================================\n");
printf("\n确定退房吗?(Y/N)\n");
while(!kbhit());
while(flag!='y'&&flag!='Y'&&flag!='n'&&flag!='N')
{
flag=getch();
flag=tolower(flag);
switch(flag)
{
case 'y':{
CUSOR->theroom.Sing=EMPTY;
customerout(&(CUSOR->theroom));
ROOMREADY++;
SAVED=0;
printf("\n退房成功!\n");
break;
}
case 'n':{printf("\n放弃退房!\n");break;}
default:{printf("\nPress y for yes or n for no!\n");break;}
}
}
printf("%s",CUSOR->theroom.Client_list.Name);
break;
}
if(CUSOR->theroom.Sing==EMPTY)
{
printf("\n退房失败:该房间目前为空房间!\n");
continue;
}
if(CUSOR->theroom.Sing==BOOKED)
{
printf("\n退房失败:该房间已被预订,并未入住,如需退订请选择退订登记!\n");
continue;
}
}
}
void ready() /*查看空房间*/
{
struct Rooms *HEAD=ROOM;
struct Rooms *CUSOR=HEAD;
unsigned roomready=0;
printf("\t\t\t ======空闲客房列表======\n");
printf("\t\t==============================================\n");
printf("\t\t 房间号 房间电话 房间价格 房间状态 \n");
printf("\t\t*--------------------------------------------*\n");
while(CUSOR!=NULL)
{
if(CUSOR->theroom.Sing==EMPTY)
{
printf("\t\t %4s %7s %4u 空闲 \n",CUSOR->theroom.Room_ID,CUSOR->theroom.Tel,CUSOR->theroom.Price);
printf("\t\t*--------------------------------------------*\n");
roomready++;
}
CUSOR=CUSOR->next;
}
printf("\t\t 合计: %u 间\n",roomready);
printf("\t\t==============================================\n");
}
void cquery() /*房客查询*/
{
char customername[20]="";
char customersex[6]="";
char customeridcard[20]="";
char chice[6]="";
char flag='x',flag1='x';
unsigned resultcnt=0;
struct Rooms *HEAD=ROOM;
struct Rooms *CUSOR=HEAD;
if(CUSOR==NULL)
{
printf("\n查询失败:酒店现无房客!\n");
return;
}
while(1)
{
HEAD=ROOM;
CUSOR=HEAD;
resultcnt=0;
printf("\n请选择以哪一项信息作为查询条件:\n");
printf("\t\t==============================================\n");
printf("\t\t 姓 名 性 别 身份证号 \n");
printf("\t\t*--------------------------------------------*\n");
printf("\t\t 1 2 3 \n");
printf("\t\t==============================================\n");
scanf("%s",chice);
if(!strcmp(chice,"1"))
{
printf("\n输入要查询的房客的姓名:");
scanf("%s",customername);
if(!strcmp(cmdtolower(chice),"quit"))
{
printf("\n放弃查询!\n");
return;
}
printf("\t\t\t ======房客查询结果======\n");
printf("\t\t==============================================\n");
printf("\t\t 姓 名 性 别 身份证号 登记时间 \n");
printf("\t\t*--------------------------------------------*\n");
while(CUSOR!=NULL)
{
if(!strcmp(customername,CUSOR->theroom.Client_list.Name))
{
printf("\t\t %6s %2s %18s %d/%d/%d\n",CUSOR->theroom.Client_list.Name,CUSOR->theroom.Client_list.Sex,CUSOR->theroom.Client_list.ID_card,CUSOR->theroom.Client_list.year,CUSOR->theroom.Client_list.month,CUSOR->theroom.Client_list.day);
printf("\t\t*--------------------------------------------*\n");
resultcnt++;
}
CUSOR=CUSOR->next;
}
printf("\t\t 合计: %u 个\n",resultcnt);
printf("\t\t==============================================\n");
while(flag1!='c'&&flag1!='C'&&flag1!='q'&&flag1!='Q')
{
printf("\n继续查询:C,退出:Q\n");
flushstdin();
flag1=getch();
flag1=tolower(flag1);
}
switch(flag1)
{
case 'c': {flag1='x';continue;break;}
case 'q': {flag1='x';printf("\n选择退出。\n");return;break;}
}
}
if(!strcmp(chice,"2"))
{
printf("\n输入要查询的房客的性别:");
scanf("%s",customersex);
if(!strcmp(cmdtolower(chice),"quit"))
{
printf("\n放弃查询!\n");
return;
}
printf("\t\t\t ======房客查询结果======\n");
printf("\t\t==============================================\n");
printf("\t\t 姓 名 性 别 身份证号 登记时间 \n");
printf("\t\t*--------------------------------------------*\n");
while(CUSOR!=NULL)
{
if(!strcmp(customersex,CUSOR->theroom.Client_list.Sex))
{
printf("\t\t %6s %2s %18s %d/%d/%d\n",CUSOR->theroom.Client_list.Name,CUSOR->theroom.Client_list.Sex,CUSOR->theroom.Client_list.ID_card,CUSOR->theroom.Client_list.year,CUSOR->theroom.Client_list.month,CUSOR->theroom.Client_list.day);
printf("\t\t*--------------------------------------------*\n");
resultcnt++;
}
CUSOR=CUSOR->next;
}
printf("\t\t 合计: %u 个\n",resultcnt);
printf("\t\t==============================================\n");
while(flag1!='c'&&flag1!='C'&&flag1!='q'&&flag1!='Q')
{
printf("\n继续查询:C,退出:Q\n");
flushstdin();
flag1=getch();
flag1=tolower(flag1);
}
switch(flag1)
{
case 'c': {flag1='x';continue;break;}
case 'q': {flag1='x';printf("\n选择退出。\n");return;break;}
}
}
if(!strcmp(chice,"3"))
{
printf("\n输入要查询的房客的身份证号:");
scanf("%s",customeridcard);
if(!strcmp(cmdtolower(chice),"quit"))
{
printf("\n放弃查询!\n");
return;
}
printf("\t\t\t ======房客查询结果======\n");
printf("\t\t==============================================\n");
printf("\t\t 姓 名 性 别 身份证号 登记时间 \n");
printf("\t\t*--------------------------------------------*\n");
while(CUSOR!=NULL)
{
if(!strcmp(customeridcard,CUSOR->theroom.Client_list.ID_card))
{
printf("\t\t %6s %2s %18s %d/%d/%d\n",CUSOR->theroom.Client_list.Name,CUSOR->theroom.Client_list.Sex,CUSOR->theroom.Client_list.ID_card,CUSOR->theroom.Client_list.year,CUSOR->theroom.Client_list.month,CUSOR->theroom.Client_list.day);
printf("\t\t*--------------------------------------------*\n");
resultcnt++;
}
CUSOR=CUSOR->next;
}
printf("\t\t 合计: %u 个\n",resultcnt);
printf("\t\t==============================================\n");
while(flag1!='c'&&flag1!='C'&&flag1!='q'&&flag1!='Q')
{
printf("\n继续查询:C,退出:Q\n");
flushstdin();
flag1=getch();
flag1=tolower(flag1);
}
switch(flag1)
{
case 'c': {flag1='x';continue;break;}
case 'q': {flag1='x';printf("\n选择退出。\n");return;break;}
}
}
if(!strcmp(chice,"quit"))
{
printf("\n放弃查询!\n");
return;
}
printf("\n无效选择!\n");
}
}
2007-07-17 21:23
mzjllh
Rank: 2
来 自:江苏扬州
等 级:论坛游民
帖 子:76
专家分:41
注 册:2007-2-8
收藏
得分:0 
void hquery() /*客房查询*/
{
char roomid[6]="";
char roomtel[12]="";
char chice[6]="";
char roomstatus[10]="";
enum housestatus roomstatus2=EMPTY;
char flag='x',flag1='x',flag2='x';
unsigned roomprice=0;
unsigned resultcnt=0;
struct Rooms *HEAD=ROOM;
struct Rooms *CUSOR=HEAD;
if(CUSOR==NULL)
{
printf("\n修改失败:酒店现无客房!\n");
return;
}
while(1)
{
HEAD=ROOM;
CUSOR=HEAD;
resultcnt=0;
printf("\n请选择以哪一项信息作为查询条件:\n");
printf("\t\t==============================================\n");
printf("\t\t 房间号 房间电话 房间价格 房间状态 \n");
printf("\t\t*--------------------------------------------*\n");
printf("\t\t 1 2 3 4 \n");
printf("\t\t==============================================\n");
scanf("%s",chice);
if(!strcmp(chice,"1"))
{
printf("\n输入要查询的房间号:");
scanf("%s",roomid);
if(!strcmp(cmdtolower(roomid),"quit"))
{
printf("\n放弃查询!\n");
return;
}
printf("\t\t\t ======客房查询结果======\n");
printf("\t\t==============================================\n");
printf("\t\t 房间号 房间电话 房间价格 房间状态 \n");
printf("\t\t*--------------------------------------------*\n");
while(CUSOR!=NULL)
{
if(!strcmp(roomid,CUSOR->theroom.Room_ID))
{
switch(CUSOR->theroom.Sing)
{
case EMPTY: {strcpy(roomstatus,"空闲");break;}
case BOOKED: {strcpy(roomstatus,"已预订");break;}
default: {strcpy(roomstatus,"已入住");break;}
}
printf("\t\t %4s %7s %4u %3s \n",CUSOR->theroom.Room_ID,CUSOR->theroom.Tel,CUSOR->theroom.Price,roomstatus);
printf("\t\t*--------------------------------------------*\n");
resultcnt++;
}
CUSOR=CUSOR->next;
}
printf("\t\t 合计: %u 间\n",resultcnt);
printf("\t\t==============================================\n");
while(flag1!='c'&&flag1!='C'&&flag1!='q'&&flag1!='Q')
{
printf("\n继续查询:C,退出:Q\n");
flushstdin();
flag1=getch();
flag1=tolower(flag1);
}
switch(flag1)
{
case 'c': {flag1='x';continue;break;}
case 'q': {flag1='x';printf("\n选择退出。\n");return;break;}
}
}
if(!strcmp(chice,"2"))
{
printf("\n输入要查询的客房的电话号码:");
scanf("%s",roomtel);
if(!strcmp(cmdtolower(roomtel),"quit"))
{
printf("\n放弃查询!\n");
return;
}
printf("\t\t\t ======客房查询结果======\n");
printf("\t\t==============================================\n");
printf("\t\t 房间号 房间电话 房间价格 房间状态 \n");
printf("\t\t*--------------------------------------------*\n");
while(CUSOR!=NULL)
{
if(!strcmp(roomtel,CUSOR->theroom.Tel))
{
switch(CUSOR->theroom.Sing)
{
case EMPTY: {strcpy(roomstatus,"空闲");break;}
case BOOKED: {strcpy(roomstatus,"已预订");break;}
default: {strcpy(roomstatus,"已入住");break;}
}
printf("\t\t %4s %7s %4u %3s \n",CUSOR->theroom.Room_ID,CUSOR->theroom.Tel,CUSOR->theroom.Price,roomstatus);
printf("\t\t*--------------------------------------------*\n");
resultcnt++;
}
CUSOR=CUSOR->next;
}
printf("\t\t 合计: %u 间\n",resultcnt);
printf("\t\t==============================================\n");
while(flag1!='c'&&flag1!='C'&&flag1!='q'&&flag1!='Q')
{
printf("\n继续查询:C,退出:Q\n");
flushstdin();
flag1=getch();
flag1=tolower(flag1);
}
switch(flag1)
{
case 'c': {flag1='x';continue;break;}
case 'q': {flag1='x';printf("\n选择退出。\n");return;break;}
}
}
if(!strcmp(chice,"3"))
{
printf("\n输入要查询的客房的价格:");
scanf("%u",&roomprice);
if(roomprice==ESC)
{
printf("\n放弃查询!\n");
return;
}
printf("\t\t\t ======客房查询结果======\n");
printf("\t\t==============================================\n");
printf("\t\t 房间号 房间电话 房间价格 房间状态 \n");
printf("\t\t*--------------------------------------------*\n");
while(CUSOR!=NULL)
{
if(roomprice==CUSOR->theroom.Price)
{
switch(CUSOR->theroom.Sing)
{
case EMPTY: {strcpy(roomstatus,"空闲");break;}
case BOOKED: {strcpy(roomstatus,"已预订");break;}
default: {strcpy(roomstatus,"已入住");break;}
}
printf("\t\t %4s %7s %4u %3s \n",CUSOR->theroom.Room_ID,CUSOR->theroom.Tel,CUSOR->theroom.Price,roomstatus);
printf("\t\t*--------------------------------------------*\n");
resultcnt++;
}
CUSOR=CUSOR->next;
}
printf("\t\t 合计: %u 间\n",resultcnt);
printf("\t\t==============================================\n");
while(flag1!='c'&&flag1!='C'&&flag1!='q'&&flag1!='Q')
{
printf("\n继续查询:C,退出:Q\n");
flushstdin();
flag1=getch();
flag1=tolower(flag1);
}
switch(flag1)
{
case 'c': {flag1='x';continue;break;}
case 'q': {flag1='x';printf("\n选择退出。\n");return;break;}
}
}
if(!strcmp(chice,"4"))
{
printf("\n选择要查询的客房的状态:\n");
printf("\t\t==============================================\n");
printf("\t\t 空 闲 已预订 已入住 \n");
printf("\t\t*--------------------------------------------*\n");
printf("\t\t 1 2 3 \n");
printf("\t\t==============================================\n");
while(flag2!='1'&&flag2!='2'&&flag2!='3')
{
flag2=getchar();
if((int)flag2==ESC)
{
printf("\n放弃查询!\n");
flag2='x';
return;
}
}
switch(flag2)
{
case '1':{
roomstatus2=EMPTY;
flag2='x';
break;
}
case '2':{
roomstatus2=BOOKED;
flag2='x';
break;
}
case '3':{
roomstatus2=CHECKEDIN;
flag2='x';
break;
}
default:{continue;break;}
}
printf("\t\t\t ======客房查询结果======\n");
printf("\t\t==============================================\n");
printf("\t\t 房间号 房间电话 房间价格 房间状态 \n");
printf("\t\t*--------------------------------------------*\n");
switch(roomstatus2)
{
case EMPTY: {strcpy(roomstatus,"空 闲");break;}
case BOOKED: {strcpy(roomstatus,"已预订");break;}
default: {strcpy(roomstatus,"已入住");break;}
}
while(CUSOR!=NULL)
{
if(roomstatus2==CUSOR->theroom.Sing)
{
printf("\t\t %4s %7s %4u %3s \n",CUSOR->theroom.Room_ID,CUSOR->theroom.Tel,CUSOR->theroom.Price,roomstatus);
printf("\t\t*--------------------------------------------*\n");
resultcnt++;
}
CUSOR=CUSOR->next;
}
printf("\t\t 合计: %u 间\n",resultcnt);
printf("\t\t==============================================\n");
while(flag1!='c'&&flag1!='C'&&flag1!='q'&&flag1!='Q')
{
printf("\n继续查询:C,退出:Q\n");
flushstdin();
flag1=getch();
flag1=tolower(flag1);
}
switch(flag1)
{
case 'c': {flag1='x';continue;break;}
case 'q': {flag1='x';printf("\n选择退出。\n");return;break;}
}
}
if(!strcmp(chice,"quit"))
{
printf("\n放弃查询!\n");
return;
}
printf("\n无效选择!\n");
}
}
void modify() /*修改房客信息*/
{
char customername[20]="";
char newname[20]="";
char newsex[6]="";
char newidcard[20]="";
char chice[6]="";
char flag='x',flag1='x';
struct Rooms *HEAD=ROOM;
struct Rooms *CUSOR=HEAD;
if(CUSOR==NULL)
{
printf("\n修改失败:酒店现无房客!\n");
return;
}
while(1)
{
printf("\n输入要修改的房客姓名:");
scanf("%s",customername);
cmdtolower(customername);
if(!strcmp(customername,"quit")) {printf("\n放弃修改!\n");break;}
HEAD=ROOM;
CUSOR=HEAD;
while(CUSOR!=NULL)
{
if(!strcmp(customername,CUSOR->theroom.Client_list.Name)) break;
CUSOR=CUSOR->next;
}
if(CUSOR==NULL)
{
printf("\n修改失败:该房客不存在!\n");
continue;
}
printf("\n房客已找到,房客信息如下:\n");
printf("\t\t==============================================\n");
printf("\t\t 姓 名 性 别 身份证号 登记时间 \n");
printf("\t\t*--------------------------------------------*\n");
printf("\t\t %6s %2s %18s %d/%d/%d\n",CUSOR->theroom.Client_list.Name,CUSOR->theroom.Client_list.Sex,CUSOR->theroom.Client_list.ID_card,CUSOR->theroom.Client_list.year,CUSOR->theroom.Client_list.month,CUSOR->theroom.Client_list.day);
printf("\t\t==============================================\n");
printf("\n确定要对其进行修改吗?(Y/N)\n");
while(flag!='y'&&flag!='Y'&&flag!='n'&&flag!='N')
{
flag=getch();
flag=tolower(flag);
switch(flag)
{
case 'y':
{
while(1)
{
printf("\n选择要修改的项目:\n");
printf("\t\t==============================================\n");
printf("\t\t 姓 名 性 别 身份证号 \n");
printf("\t\t*--------------------------------------------*\n");
printf("\t\t 1 2 3 \n");
printf("\t\t==============================================\n");
scanf("%s",chice);
if(!strcmp(chice,"1"))
{
while(1)
{
printf("\n修改房客姓名:");
scanf("%s",newname);
if(!strcmp(cmdtolower(newname),"quit"))
{
printf("\n放弃修改!\n");
return;
}
strcpy(CUSOR->theroom.Client_list.Name,newname);
SAVED=0;
printf("\n修改成功!\n");
while(flag1!='c'&&flag1!='C'&&flag1!='q'&&flag1!='Q')
{
printf("\n继续修改其他项目:C,退出:Q\n");
while(!kbhit());
flushstdin();
flag1=getch();
flag1=tolower(flag1);
}
break;
}
switch(flag1)
{
case 'c': {flag1='x';continue;break;}
case 'q': {flag1='x';printf("选择退出。");return;break;}
}
}
if(!strcmp(chice,"2"))
{
while(1)
{
printf("\n修改房客性别:");
scanf("%s",newsex);
if(!strcmp(cmdtolower(newsex),"quit"))
{
printf("\n放弃修改!\n");
return;
}
strcpy(CUSOR->theroom.Client_list.Sex,newsex);
SAVED=0;
printf("\n修改成功!\n");
while(flag1!='c'&&flag1!='C'&&flag1!='q'&&flag1!='Q')
{
printf("\n继续修改其他项目:C,退出:Q\n");
while(!kbhit());
flushstdin();
flag1=getch();
flag1=tolower(flag1);
}
break;
}
switch(flag1)
{
case 'c': {flag1='x';continue;break;}
case 'q': {flag1='x';printf("选择退出。");return;break;}
}
}
if(!strcmp(chice,"3"))
{
while(1)
{
printf("\n修改房客身份证号:");
scanf("%s",newidcard);
if(!strcmp(cmdtolower(newidcard),"quit"))
{
printf("\n放弃修改!\n");
return;
}
strcpy(CUSOR->theroom.Client_list.ID_card,newidcard);
SAVED=0;
printf("\n修改成功!\n");
while(flag1!='c'&&flag1!='C'&&flag1!='q'&&flag1!='Q')
{
printf("\n继续修改其他项目:C,退出:Q\n");
while(!kbhit());
flushstdin();
flag1=getch();
flag1=tolower(flag1);
}
break;
}
switch(flag1)
{
case 'c': {flag1='x';continue;break;}
case 'q': {flag1='x';printf("选择退出。");return;break;}
}
}
if(!strcmp(chice,"quit")) {flag1='x';printf("选择退出。");return;break;}
printf("\n无效选择!\n");
continue;
}
break;
}
case 'n':{printf("\n放弃修改!\n");break;}
default:{printf("\nPress y for yes or n for no!\n");break;}
}
}
break;
}
}
2007-07-17 21:24
mzjllh
Rank: 2
来 自:江苏扬州
等 级:论坛游民
帖 子:76
专家分:41
注 册:2007-2-8
收藏
得分:0 
void rebuild() /*修改房间信息*/
{
char roomid[6]="";
char newroomid[6]="";
char newtel[12]="";
unsigned newprice=0;
char chice[6]="";
char flag='x',flag1='x',flag2='x';
struct Rooms *HEAD=ROOM;
struct Rooms *CUSOR=HEAD;
char roomstatus[10];
if(CUSOR==NULL)
{
printf("\n修改失败:酒店现无客房!\n");
return;
}
while(1)
{
printf("\n输入要修改的房间号:");
scanf("%s",roomid);
cmdtolower(roomid);
if(!strcmp(roomid,"quit")) {printf("\n放弃修改!\n");break;}
HEAD=ROOM;
CUSOR=HEAD;
while(CUSOR!=NULL)
{
if(!strcmp(roomid,CUSOR->theroom.Room_ID)) break;
CUSOR=CUSOR->next;
}
if(CUSOR==NULL)
{
printf("\n修改失败:房间号不存在!\n");
continue;
}
switch(CUSOR->theroom.Sing)
{
case EMPTY: {strcpy(roomstatus,"空 闲");break;}
case BOOKED: {strcpy(roomstatus,"已预订");break;}
default: {strcpy(roomstatus,"已入住");break;}
}
printf("\n房间已找到,房间信息如下:\n");
printf("\t\t==============================================\n");
printf("\t\t 房间号 房间电话 房间价格 房间状态 \n");
printf("\t\t*--------------------------------------------*\n");
printf("\t\t %4s %7s %4u %3s \n",CUSOR->theroom.Room_ID,CUSOR->theroom.Tel,CUSOR->theroom.Price,roomstatus);
printf("\t\t==============================================\n");
printf("\n确定要对其进行修改吗?(Y/N)\n");
while(!kbhit());
while(flag!='y'&&flag!='Y'&&flag!='n'&&flag!='N')
{
flag=getch();
flag=tolower(flag);
switch(flag)
{
case 'y':
{
while(1)
{
printf("\n选择要修改的项目:\n");
printf("\t\t==============================================\n");
printf("\t\t 房间号 房间电话 房间价格 房间状态 \n");
printf("\t\t*--------------------------------------------*\n");
printf("\t\t 1 2 3 4 \n");
printf("\t\t==============================================\n");
scanf("%s",chice);
if(!strcmp(chice,"1"))
{
while(1)
{
printf("\n修改房间号:");
scanf("%s",newroomid);
if(!strcmp(cmdtolower(newroomid),"quit"))
{
printf("\n放弃修改!\n");
return;
}
if(roomidexists(newroomid))
{
printf("\n该房间号已存在!\n");
continue;
}
strcpy(CUSOR->theroom.Room_ID,newroomid);
SAVED=0;
printf("\n修改成功!\n");
while(flag1!='c'&&flag1!='C'&&flag1!='q'&&flag1!='Q')
{
printf("\n继续修改其他项目:C,退出:Q\n");
while(!kbhit());
flushstdin();
flag1=getch();
flag1=tolower(flag1);
}
break;
}
switch(flag1)
{
case 'c': {flag1='x';continue;break;}
case 'q': {flag1='x';printf("选择退出。");return;break;}
}
}
if(!strcmp(chice,"2"))
{
while(1)
{
printf("\n修改房间电话:");
scanf("%s",newtel);
if(!strcmp(cmdtolower(newtel),"quit"))
{
printf("\n放弃修改!\n");
return;
}
if(telexists(newtel))
{
printf("\n该电话号码已存在!\n");
continue;
}
strcpy(CUSOR->theroom.Tel,newtel);
printf("\n修改成功!\n");
while(flag1!='c'&&flag1!='C'&&flag1!='q'&&flag1!='Q')
{
printf("\n继续修改其他项目:C,退出:Q\n");
while(!kbhit());
flushstdin();
flag1=getch();
flag1=tolower(flag1);
}
break;
}
switch(flag1)
{
case 'c': {flag1='x';continue;break;}
case 'q': {flag1='x';printf("选择退出。");return;break;}
}
}
if(!strcmp(chice,"3"))
{
while(1)
{
printf("\n修改房间价格:");
scanf("%u",&newprice);
if(newprice==ESC)
{
printf("\n放弃修改!\n");
return;
}
CUSOR->theroom.Price=newprice;
SAVED=0;
printf("\n修改成功!\n");
while(flag1!='c'&&flag1!='C'&&flag1!='q'&&flag1!='Q')
{
printf("\n继续修改其他项目:C,退出:Q\n");
while(!kbhit());
flushstdin();
flag1=getch();
flag1=tolower(flag1);
}
break;
}
switch(flag1)
{
case 'c': {flag1='x';continue;break;}
case 'q': {flag1='x';printf("选择退出。");return;break;}
}
}
if(!strcmp(chice,"4"))
{
while(1)
{
printf("\n修改房间状态,请选择:\n");
printf("\t\t==============================================\n");
printf("\t\t 空 闲 已预订 已入住 \n");
printf("\t\t*--------------------------------------------*\n");
printf("\t\t 1 2 3 \n");
printf("\t\t==============================================\n");
while(flag2!='1'&&flag2!='2'&&flag2!='3')
{
flag2=getch();
if((int)flag2==ESC)
{
printf("\n放弃修改!\n");
return;
}
}
switch(flag2)
{
case '1':{
if(CUSOR->theroom.Sing!=EMPTY)
{
CUSOR->theroom.Sing=EMPTY;
ROOMREADY++;
}
break;
}
case '2':{
if(CUSOR->theroom.Sing!=BOOKED)
{
CUSOR->theroom.Sing=BOOKED;
ROOMREADY--;
}
break;
}
case '3':{
if(CUSOR->theroom.Sing!=CHECKEDIN)
{
CUSOR->theroom.Sing=CHECKEDIN;
ROOMREADY--;
}
break;
}
default:{continue;break;}
}
SAVED=0;
printf("\n修改成功!\n");
while(flag1!='c'&&flag1!='C'&&flag1!='q'&&flag1!='Q')
{
printf("\n继续修改其他项目:C,退出:Q\n");
flag1=getch();
flag1=tolower(flag1);
}
break;
}
switch(flag1)
{
case 'c': {flag1='x';continue;break;}
case 'q': {flag1='x';printf("选择退出。");return;break;}
}
}
if(!strcmp(chice,"quit")) {flag1='x';printf("选择退出。");return;break;}
printf("\n无效选择!\n");
continue;
}
break;
}
case 'n':{printf("\n放弃修改!\n");break;}
default:{printf("\nPress y for yes or n for no!\n");break;}
}
}
break;
}
}
void cls() /*清屏*/
{
system("cls");
}
void modicolor() /*调整界面着色*/
{
char colorcmd[10]="color ";
char color[5]="";
char bgcolor[10]="";
char forcolor[10]="";
cls();
printf("\n");
printf("\t\t =============================================\n");
printf("\t\t * 界 面 着 色 调 整 选 单 *\n");
printf("\t\t *===========================================*\n");
printf("\t\t * 颜 色 标 识 数 值 *\n");
printf("\t\t *                     *\n");
printf("\t\t * 黑 BLACK 0 *\n");
printf("\t\t *                     *\n");
printf("\t\t * 蓝 BLUE 1 *\n");
printf("\t\t *                     *\n");
printf("\t\t * 绿 GREEN 2 *\n");
printf("\t\t *                     *\n");
printf("\t\t * 红 RED 4 *\n");
printf("\t\t *                     *\n");
printf("\t\t * 黄 YELLOW 6 *\n");
printf("\t\t *                     *\n");
printf("\t\t * 白 WHITE 7 *\n");
printf("\t\t *___________________________________________*\n");
printf("\t\t * 注:选择时可以键入标识或数值。 *\n");
printf("\t\t =============================================\n");
while(1)
{
printf("\n请选择背景色:");
scanf("%s",bgcolor);
flushstdin();
cmdtolower(bgcolor);
if(!(strcmp(bgcolor,"black")&&strcmp(bgcolor,BLACK)))
{strcpy(bgcolor,BLACK);break;}
if(!(strcmp(bgcolor,"blue")&&strcmp(bgcolor,BLUE)))
{strcpy(bgcolor,BLUE);break;}
if(!(strcmp(bgcolor,"green")&&strcmp(bgcolor,GREEN)))
{strcpy(bgcolor,GREEN);break;}
if(!(strcmp(bgcolor,"red")&&strcmp(bgcolor,RED)))
{strcpy(bgcolor,RED);break;}
if(!(strcmp(bgcolor,"yellow")&&strcmp(bgcolor,YELLOW)))
{strcpy(bgcolor,YELLOW);break;}
if(!(strcmp(bgcolor,"white")&&strcmp(bgcolor,WHITE)))
{strcpy(bgcolor,WHITE);break;}
if(!strcmp(bgcolor,"quit"))
{printf("\n放弃设置!\n");return;}
printf("\n无效选择!\n");
}
while(1)
{
printf("\n请选择前景色:");
scanf("%s",forcolor);
flushstdin();
cmdtolower(forcolor);
if(!(strcmp(forcolor,"black")&&strcmp(forcolor,BLACK)))
{strcpy(forcolor,BLACK);break;}
if(!(strcmp(forcolor,"blue")&&strcmp(forcolor,BLUE)))
{strcpy(forcolor,BLUE);break;}
if(!(strcmp(forcolor,"green")&&strcmp(forcolor,GREEN)))
{strcpy(forcolor,GREEN);break;}
if(!(strcmp(forcolor,"red")&&strcmp(forcolor,RED)))
{strcpy(forcolor,RED);break;}
if(!(strcmp(forcolor,"yellow")&&strcmp(forcolor,YELLOW)))
{strcpy(forcolor,YELLOW);break;}
if(!(strcmp(forcolor,"white")&&strcmp(forcolor,WHITE)))
{strcpy(forcolor,WHITE);break;}
if(!strcmp(forcolor,"quit"))
{printf("\n放弃设置!\n");return;}
printf("\n无效选择!\n");
}
strcpy(BGCOLOR,bgcolor);
strcpy(FORCOLOR,forcolor);
strcpy(color,strcat(bgcolor,forcolor));
strcpy(COLOR,strcat(BGCOLOR,FORCOLOR));
if(!system(strcat(colorcmd,color)))printf("\n设置成功!\n");
}
void dispmenu() /*显示菜单*/
{
cls();
printf("\n");
printf("\t\t =============================================\n");
printf("\t\t * 酒 店 客 房 管 理 系 统 *\n");
printf("\t\t *===========================================*\n");
printf("\t\t * 1.载入客房台账   10.客房信息查询 *\n");
printf("\t\t *                     *\n");
printf("\t\t *  2.保存客房台账    11.客房信息修正 *\n");
printf("\t\t *                     *\n");
printf("\t\t *  3.房客入住登记    12.新增客房登记 *\n");
printf("\t\t *                     *\n");
printf("\t\t *  4.房客退房登记    13.客房业务统计 *\n");
printf("\t\t *                     *\n");
printf("\t\t *  5.房间预订登记    14.清除屏幕信息 *\n");
printf("\t\t *                     *\n");
printf("\t\t *  6.房间退订登记     15.界面着色调整 *\n");
printf("\t\t *                     *\n");
printf("\t\t *  7.空闲房间列表    16.显示系统菜单 *\n");
printf("\t\t *                     *\n");
printf("\t\t *  8.房客信息查询    17.显示帮助信息 *\n");
printf("\t\t *                     *\n");
printf("\t\t *  9.房客信息修正    18.安全退出系统 *\n");
printf("\t\t ---------------------------------------------\n");
printf("\t\t * 注:可使用数字或命令进入,具体参见帮助信息. *\n");
printf("\t\t =============================================\n");
}
void testsave() /*当前台账是否保存*/
{
char flag='x';
if(!SAVED)
{
printf("\n台账已被修改,现在保存吗?(Y/N)\n");
flag=tolower(flag);
while(flag!='y'&&flag!='n')
{
flag=getch();
flag=tolower(flag);
if(flag==ESC)
{
printf("\n放弃保存!\n");
return;
}
}
if(flag=='y') save();
else printf("\n放弃保存!\n");
}
}
void addhouse() /*新增房间*/
{
struct Rooms *new=malloc(sizeof(struct Rooms));
printf("\t\t\t ======填写新增房间信息======\n");
while(1)
{
printf("\n新增房间号:");
scanf("%s",new->theroom.Room_ID);
if(!strcmp(cmdtolower(new->theroom.Room_ID),"quit"))
{
printf("\n放弃新增!\n");
return;
}
if(roomidexists(new->theroom.Room_ID))
{
printf("\n该房间号已存在!\n");
continue;
}
break;
}
printf("\n新增房间电话:");
scanf("%s",new->theroom.Tel);
printf("\n新增房间价格:");
scanf("%u",&(new->theroom.Price));
new->theroom.Sing=EMPTY;
if(ROOM==NULL)
{
ROOM=new;
Roomtail=new;
Roomtail->before=NULL;
}
else
{
Roomtail->next=new;
Roomtail->next->before=Roomtail;
Roomtail=Roomtail->next;
}
Roomtail->next=NULL;
ROOMCNT++;
ROOMREADY++;
SAVED=0;
new=NULL;
printf("\n新增房间成功!\n");
}
2007-07-17 21:24
mzjllh
Rank: 2
来 自:江苏扬州
等 级:论坛游民
帖 子:76
专家分:41
注 册:2007-2-8
收藏
得分:0 
void load() /*载入台账*/
{
char loadpath[50]=SPACE;
char flag='x';
unsigned loadcnt=0;
struct Rooms *HEAD=NULL;
struct Rooms *CUSOR=HEAD;
FILE *LOADFROM;
testsave();
printf("\t\t\t ======载入已存台账======\n");
while(1)
{
//if(!strcmp(LOADPATH,DEFAULTPATH))
{
printf("\n从默认位置 %s 载入吗?(Y/N)\n",DEFAULTPATH);
flag=tolower(flag);
while(flag!='y'&&flag!='n')
{
flag=getch();
flag=tolower(flag);
if(flag==ESC)
{
printf("\n放弃载入!\n");
return;
}
}
if(flag=='y') {strcpy(loadpath,DEFAULTPATH);}
}
if(flag=='n')
{
printf("\n输入载入路径:");
scanf("%s",loadpath);
}
flag='x';
if((LOADFROM=fopen(loadpath,"rb"))==NULL)
{
printf("\n文件载入失败!\n");
continue;
}
printf("\n正在载入...\n");
ROOM=NULL;
HEAD=malloc(sizeof(struct Rooms));
HEAD->before=NULL;
HEAD->next=NULL;
CUSOR=HEAD;
while(!feof(LOADFROM))
{
fread(&(CUSOR->theroom),sizeof(struct Hotel),1,LOADFROM);
loadcnt++;
if(CUSOR->theroom.Sing==EMPTY) ROOMREADY++;
ROOMCNT++;
CUSOR->next=malloc(sizeof(struct Rooms));
CUSOR->next->before=CUSOR;
CUSOR=CUSOR->next;
}
if(loadcnt>1) CUSOR=CUSOR->before->before;
else CUSOR=CUSOR->before;
CUSOR->next=NULL;
fclose(LOADFROM);
ROOM=HEAD;
Roomtail=CUSOR;
SAVED=1;
printf("\n载入成功!\n");
strcpy(LOADPATH,loadpath);
break;
}
}
void help() /*显示帮助信息*/
{
cls();
printf("\t\t ==============================================\n");
printf("\t\t * 帮 助 信 息 *\n");
printf("\t\t *============================================*\n");
printf("\t\t *一.系统选单提供了数字选项与命令两种模式控制 *\n");
printf("\t\t *                      *\n");
printf("\t\t *-----------以下是选项与命令对照表-----------*\n");
printf("\t\t *                      *\n");
printf("\t\t *载入客房台账:LOAD 客房信息查询:HQUERY *\n");
printf("\t\t *                     *\n");
printf("\t\t *保存客房台账:SAVE 客房信息修正:REBUILD *\n");
printf("\t\t *                     *\n");
printf("\t\t *房客入住登记:CHECKIN 新增客房登记:ADDHOUSE *\n");
printf("\t\t *                     *\n");
printf("\t\t *房客退房登记:CHECKOUT 客房业务统计:STATISTIC*\n");
printf("\t\t *                     *\n");
printf("\t\t *房间预订登记:BOOK   清除屏幕信息:CLS *\n");
printf("\t\t *                     *\n");
printf("\t\t *房间退订登记:UNBOOK  界面着色调整:MODICOLOR*\n");
printf("\t\t *                      *\n");
printf("\t\t *空闲房间列表:READY  显示系统菜单:MENU *\n");
printf("\t\t *                     *\n");
printf("\t\t *房客信息查询:CQUERY  显示帮助信息:HELP *\n");
printf("\t\t *                     *\n");
printf("\t\t *房客信息修正:MODIFY  安全退出系统:EXIT *\n");
printf("\t\t *--------------------------------------------*\n");
printf("\t\t * 注:命令不区分大小写,可随意输入.*\n");
printf("\t\t ==============================================\n");
system("pause");
cls();
printf("\t\t ==============================================\n");
printf("\t\t * 帮 助 信 息 *\n");
printf("\t\t *============================================*\n");
printf("\t\t * 二.系统各子模块中大部分接受字符串或数字输入*\n");
printf("\t\t *                      *\n");
printf("\t\t * 的地方可以通过键入\"quit\"或按ESC键以退出该模*\n");
printf("\t\t *                      *\n");
printf("\t\t * 块。比如在要求输入查询房间号时,如果想此时退*\n");
printf("\t\t *                     *\n");
printf("\t\t * 出,可以直接键入\"quit\"字符串放弃查询。这里的*\n");
printf("\t\t *                     *\n");
printf("\t\t * \"quit\"字符串也不区分大小写,可大写、小写或大*\n");
printf("\t\t *                     *\n");
printf("\t\t * 小写混合使用。 *\n");
printf("\t\t ==============================================\n");
printf("\n");
printf("\t\t ==================帮 助 结 束=================\n");
}
2007-07-17 21:25
快速回复:C语言实习题目,自己不行了..搞不定回不了家了....
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029664 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved