printf(\继续系统操作?yes or no;请输入 Y 或者 N:\ch=getchar(); getchar();
if(ch=='y'||ch=='Y') { goto lop; }
return 0; } /**
*函数名称:creat_list
*函数功能:创建链表,进行最初的数据输入 *输入参数::无
*输出参数:head主链头指针的地址,用来返回创建的十字链 *返回值:无
*调用说明:进行最初的数据输入 */
void create_list(ROOM_TYPE** head) {
ROOM_TYPE *hdtype=NULL,*ptype; ROOM_NOTE *pnote; GUEST *pguest; char ch; int find=0; loop:
ptype=(ROOM_TYPE*)malloc(sizeof(ROOM_TYPE));
printf(\输入入住房间的类型:A(标准单人间),B(标准双人间),C(套房):\
scanf(\getchar();
if(ptype->roomtype=='a'||ptype->roomtype=='A') {
ptype->standardprice=100; ptype->hourprice=30; }
if(ptype->roomtype=='b'||ptype->roomtype=='B') {
ptype->standardprice=200; ptype->hourprice=60; }
if(ptype->roomtype=='c'||ptype->roomtype=='C') {
ptype->hourprice=300;
11
ptype->standardprice=90; }
ptype->next2=NULL; ptype->next=hdtype; hdtype=ptype;
printf(\继续录入房间类型信息:yes or no?输入 Y 或者 N:\ch=getchar(); getchar();
if(ch=='y'||ch=='Y') goto loop;
*head=hdtype;
printf(\输入房间基本信息:yes or no,输入 Y 或者 N:\ch=getchar(); getchar(); loop1: ptype=*head;
while(ch=='Y'||ch=='y') {
pnote=(ROOM_NOTE*)malloc(sizeof(ROOM_NOTE)); printf(\输入房间号码:\scanf(\getchar();
printf(\输入房间类型(A,B,C……):\scanf(\getchar();
printf(\输入房间所在层号(1,2,3……):\scanf(\getchar();
printf(\输入房间位置(A,B,C……):\scanf(\getchar();
printf(\输入房间电话号码:\scanf(\getchar();
pnote->next3=NULL;
while(ptype!=NULL&&ptype->roomtype!=pnote->roomType) { ptype=ptype->next; } if(ptype!=NULL) {
12
pnote->next=ptype->next2; ptype->next2=pnote; } else
{ free(pnote);
printf(\房间类型有问题\\n\
printf(\重新再输入此房间基本信息:yes or no 输入 Y 或者 N:\
ch=getchar(); getchar();
if(ch=='y'||ch=='Y') goto loop1; }
printf(\继续输入其它房间基本信息:yes or no 输入 Y 或者 N:\
ch=getchar(); getchar(); }
printf(\输入旅客入住基本信息:yes or no 输入 Y 或者 N:\ch=getchar(); getchar();
while(ch=='y'||ch=='Y') {
pguest=(GUEST*)malloc(sizeof(GUEST));
printf(\输入旅客姓名(用拼音):\scanf(\getchar();
printf(\输入房间号码:\scanf(\getchar();
printf(\输入旅客身份证号:\scanf(\getchar();
printf(\输入旅客性别(M,男;F,女):\scanf(\getchar();
printf(\输入旅客出生日期(格式xxxx/xx/xx;例1990/06/01):\scanf(\getchar();
printf(\输入旅客入住日期(格式xxxx/xx/xx;例2011/09/01):\scanf(\getchar();
printf(\输入旅客退房日期(格式xxxx/xx/xx;例2011/09/01):\
13
scanf(\getchar();
printf(\输入旅客联系电话:\scanf(\getchar(); ptype=*head; find=0;
while(ptype!=NULL&&find==0) {
pnote=ptype->next2;
while(pnote!=NULL&&find==0) {
if(strcmp(pnote->roomNum,pguest->roomNum)==0) { find=1; break;
} pnote=pnote->next; } ptype=ptype->next; } if(find)
{
pguest->next=pnote->next3; pnote->next3=pguest; } else
{ free(pguest);
printf(\房间号码有问题\\n\ }
printf(\继续输入旅客入住基本信息:yes or no 输入 Y 或者N:\
ch=getchar(); getchar(); } } /**
*函数名称:save_list
*函数功能:保存链表到硬盘 *输入参数::主链头指针head *输出参数:无 *返回值:无
14
*调用说明: */
void save_list(ROOM_TYPE* head) {
FILE *out1,*out2,*out3; ROOM_TYPE *ptype=head; ROOM_NOTE *pnote; GUEST *pguest;
if((out1=fopen(\exit(-1);
if((out2=fopen(\exit(-1);
if((out3=fopen(\exit(-1);
while(ptype!=NULL) {
fwrite(ptype,sizeof(ROOM_TYPE),1,out1); pnote=ptype->next2; while(pnote!=NULL) {
fwrite(pnote,sizeof(ROOM_NOTE),1,out2); pguest=pnote->next3; while(pguest!=NULL) {
fwrite(pguest,sizeof(GUEST),1,out3); pguest=pguest->next; } pnote=pnote->next; }
ptype=ptype->next; }
fclose(out1); fclose(out2); fclose(out3);
printf(\数据保存成功!\\n\} /**
*函数名称:load_list
*函数功能:加载保存的数据到链表中 *输入参数::无
*输出参数:head主链头指针的地址,用来返回加载的十字链15
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说综合文库c语言课程设计实验报告(3)在线全文阅读。
相关推荐: