77范文网 - 专业文章范例文档资料分享平台

c语言课程设计实验报告(3)

来源:网络收集 时间:2019-04-21 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

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)在线全文阅读。

c语言课程设计实验报告(3).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/zonghe/609050.html(转载请注明文章来源)
Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: