C语言课程设计宾馆住宿系统_第1页
C语言课程设计宾馆住宿系统_第2页
C语言课程设计宾馆住宿系统_第3页
C语言课程设计宾馆住宿系统_第4页
C语言课程设计宾馆住宿系统_第5页
已阅读5页,还剩32页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、华中科技大学计算机科学与技术学院C语言程序设计课程设计实验报告题目: 宾馆住宿信息管理系统 专业: 班级: 学号: 姓名: 成绩: 指导教师: 完成日期: 20年 10 月 1 日宾馆管理住宿系统一实验目的:1、进一步掌握和利用C语言进行程设计的能力; 2、 进一步理解和运用结构化程设计的思想和方法; 3、 初步掌握开发一个小型实用系统的基本方法; 4、 学会调试一个较长程序的基本方法; 5、 学会利用流程图或N-S图表示算法; 6、 掌握书写程设计开发文档的能力(书写课程设计报告);二实验要求:1、只能使用C语言,源程序要有适当的注释,使程序容易阅读。2、要有用户界面。要求至少采用简易菜单;

2、鼓励采用文本菜单界面甚至采用图形菜单界面。3、必须使用结构和十字交叉链表等数据结构。4、使用文件保存数据。5、至少输出一份报表(屏幕输出即可),鼓励自行增加新功能。功能要求(宾馆住宿信息管理系统): 对宾馆所有客房的住宿信息进行管理,主要包括客房基本信息、客户住宿信息。包含功能:客房基本信息录入。允许对已经录入的数据重新进行编辑、修改,各种基本数据的插入、删除,基于各种数据的查询、统计计算。宾馆住宿信息其它方面的统计(自行确定)。三实验内容:程序概况本程序采用文本菜单界面,程序数据结构采用三个方向的十字链表来处理的。具有对客房基本信息,客户信息的新建、修改、插入、删除、查找、查看、统计、保存、

3、载入等功能。程序虽简单,但具有完整的功能。程序模块示意图1) 主程序流程图开始功能选择菜单判断选择保存数据结束新建插入 修改删除保存统计查找浏览载入获取按键2)主要数据结构图程序数据结构采用三个方向的十字链表来处理的。程序详细介绍主要数据结构:typedef struct kehuxinxi char name20;/*客户姓名*/ char id20;/*客户ID*/ char sex;/*性别*/ char telephone20;/*电话*/char room10;/*房间号*/char time12;/*入住时间*/float yingshou;/*应付费用*/float shisho

4、u;/*实际费用*/char shouyinyuan20;/*收银员*/struct kehuxinxi * next; kehu,* Pkehu;客户信息包含客户姓名,ID,性别,房间号,入住时间,应付费用,实际费用,收银员的资料。typedef struct kefangxinxi char num10;/*房间号*/ char zhonglei;/*类别*/ int times;/*入住次数*/ float jiage;/*价格*/ struct kefangxinxi * next; Pkehu Record; fangjian,* Pfangjian; 客房信息里包含房间号,房间类别

5、,入住次数,房间价格资料。 typedef struct kefangzhonglei char zhonglei;/*类别*/ int shuliang;/*房间数*/ Pfangjian first; struct kefangzhonglei * next; fangjianzhonglei ,* Pfangjianzhonglei;房间种类包含房间类别和房间数目资料。各函数功能介绍(为方便阅读理解程序,函数名用汉语拼音代替)int xiangdaohejiemian(int function,Pfangjianzhonglei * pRST);绘制功能选择界面int Collect(i

6、nt (* Comp)(void *,void *),int num);按照Comp规则收集前num个信息int jiyushijian(void *,void *);按照次数规则int jiyujiage(void *,void *);按照价格规则int huodecaidan(char * * szTitles,int num);获取菜单int huodekefangzhonglei(FILE * pf,Pfangjianzhonglei sub_tree);获取一整个类型,客房种类int huodekefang(FILE * pf,Pfangjian room);获取一个房间信息int

7、huodekehu(FILE * pf,Pkehu custom);获取一个客户信息int xierukefangxinxi(FILE * pf,Pfangjian room);写入客房信息int xierukehuxinxi(FILE * pf,Pkehu custom);写入客户信息int huodenkefang(Pfangjianzhonglei sub_tree,int num_room);获取num_room个房间intxiugaikehuxinxi(Pkehu pCu);修改客户信息int xiugaikefangxinxi(Pfangjian pRF);修改房间信息int Co

8、llect(int (* Comp)(void *,void *),int num);按照Comp规则收集前num个信息int jiyushijian(void *,void *);按照次数规则int jiyujiage(void *,void *);按照价格规则int Display(void);int Get_Info(char * * szTitles,char * * buffer,int num);int zhanxiankehu(Pkehu pCu);int zhanxiankefang(Pfangjian pRF);显示客房客户信息int huodekehuxinxi(Pkehu

9、 pCu);获取客户信息int sousuokefangzhonglei(Pfangjianzhonglei pRST);搜索一个类型客房种类int sousuokefangxinxi(Pfangjianzhonglei pRST);搜索一个客房int sousuokehu(Pfangjianzhonglei pRST);搜索一个客户int tianjiazhonglei(Pfangjianzhonglei pRST);插入客房种类int tianjiakefang(Pfangjianzhonglei pRST);插入一个客房int tianjiakehu(Pfangjianzhonglei

10、pRST);插入一个客户int shanchuzhonglei(Pfangjianzhonglei * pRST);删除客房种类int shanchukefang(Pfangjianzhonglei * pRST);删除客房信息int shanchukehu(Pfangjianzhonglei * pRST);删除客户信息int xiugaikefangzhonglei(Pfangjianzhonglei pRST);/修改客房种类int xiugaikehu(Pfangjianzhonglei pRST);修改客户信息int huodekefangxinxi(Pfangjian pRF);获

11、得客房信息/*Qsort*/void Qsort(void * * array,int low,int high,int (*Comp)(void * ,void * );快速排序法排序四运行结果1开始功能选择菜单2新建功能界面3插入功能界面4修改功能界面5删除功能界面6查找功能界面7查看功能界面详细设计:(源程序清单见附录):五心得体会 通过这次实训,增加了我学习软件技术的兴趣,虽然在编写修改代码的工程中花费了不少时间甚至有放弃的想法,但最终看到程序运行,那种喜悦兴奋之情无法用文字描述。1. 编写课程设计是理论结合实际的一次很好结合,虽然写得作业仅仅只能当做一项作业没有实际使用的价值,但还是

12、从中学到了不少,真正地体会到完成一项任务的艰辛和付出之后收获的快乐。2. 编写程序时应该使程序易于理解尽量使用通用的变量名和通俗的注释。3. 虽然很多东西刚开始时都不懂,但只要坚持下去学,慢慢地就会熟悉。4. 程序应该分几个文件装,要有条理性。5. 写程序运行时会出现很多bug,要耐心调试,编程需要耐心和细心。把程序完整地调试好后,对自己性格的培养也是一种提高。6. 当自己解决不了时要向他人请教,虚心学习他人的方法。这次完成作业向同学们请教了很多问题,得到了同学的帮助,在此真心地表示感谢。参考文献Turbo C 使用大全第一册、第二册 徐金梧等编译 北京科海培训中心C语言课程设计 曹计昌 卢萍

13、 李开 编著C程序设计谭浩强 著附录源程序清单#ifndef DEF#define DEF#define BUFSIZE 20#define MAX_ROOM 100#define TEXT_CY 20#include<math.h>#include<stdio.h>#include<dos.h>#include<conio.h>#include<malloc.h>#include<string.h>#include<stdlib.h>#define TRUE 1#define FALSE 0#define N

14、AME 20#define MAX_ID 20#define NUM 10#define TELE 20#define TIME 12typedef struct kehuxinxi char name20;/*客户姓名*/ char id20;/*客户ID*/ char sex;/*性别*/ char telephone20;/*电话*/char room10;/*房间号*/char time12;/*入住时间*/float yingshou;/*应付费用*/float shishou;/*实际费用*/char shouyinyuan20;/*收银员*/struct kehuxinxi *

15、next; kehu,* Pkehu;typedef struct kefangxinxi char num10;/*房间号*/ char zhonglei;/*类别*/ int times;/*入住次数*/ float jiage;/*价格*/ struct kefangxinxi * next; Pkehu Record; fangjian,* Pfangjian; typedef struct kefangzhonglei char zhonglei;/*类别*/ int shuliang;/*房间数*/ Pfangjian first; struct kefangzhonglei *

16、next; fangjianzhonglei ,* Pfangjianzhonglei;typedef structfangjian * Buffer;int Bufsize;/*缓冲区大小*/Buf;typedef structint left;int top;int right;int bottom;Rect;/*矩形区域,一个好东西*/*Guide*/int xiangdaohejiemian(int function,Pfangjianzhonglei * pRST);/*tools*/int Collect(int (* Comp)(void *,void *),int num);/

17、*按照Comp规则收集前num个信息*/int jiyushijian(void *,void *);/*按照次数规则*/int jiyujiage(void *,void *);/*按照价格规则*/int huodecaidan(char * * szTitles,int num);/*fun_fun*/int huodekefangzhonglei(FILE * pf,Pfangjianzhonglei sub_tree);/*获取一整个类型*/int huodekefang(FILE * pf,Pfangjian room);/*获取一个房间*/int huodekehu(FILE *

18、pf,Pkehu custom);/*获取一个客户*/int xierukefang(FILE * pf,Pfangjianzhonglei sub_tree);int xierukefangxinxi(FILE * pf,Pfangjian room);int xierukehuxinxi(FILE * pf,Pkehu custom);int huodenkefang(Pfangjianzhonglei sub_tree,int num_room);/*获取num_room个房间*/intxiugaikehuxinxi(Pkehu pCu);/*修改客户信息*/int xiugaikefa

19、ngxinxi(Pfangjian pRF);/*修改房间信息*/int Collect(int (* Comp)(void *,void *),int num);/*按照Comp规则收集前num个信息*/int jiyushijian(void *,void *);/*按照次数规则*/int jiyujiage(void *,void *);/*按照价格规则*/int Display(void);int Get_Info(char * * szTitles,char * * buffer,int num);int zhanxiankehu(Pkehu pCu);int zhanxiankef

20、ang(Pfangjian pRF);int huodekehuxinxi(Pkehu pCu);int sousuokefangzhonglei(Pfangjianzhonglei pRST);/*搜索一个类型*/int sousuokefangxinxi(Pfangjianzhonglei pRST);/*搜一个房间*/int sousuokehu(Pfangjianzhonglei pRST);/*搜一个客户*/int tianjiazhonglei(Pfangjianzhonglei pRST);/*插入*/int tianjiakefang(Pfangjianzhonglei pRS

21、T);int tianjiakehu(Pfangjianzhonglei pRST);int shanchuzhonglei(Pfangjianzhonglei * pRST);/*删除*/int shanchukefang(Pfangjianzhonglei * pRST);int shanchukehu(Pfangjianzhonglei * pRST);int xiugaikefangzhonglei(Pfangjianzhonglei pRST);/*修改*/int xiugaikehu(Pfangjianzhonglei pRST);int huodekefangxinxi(Pfan

22、gjian pRF);intBuf_Clear(void);intBuf_Fill_Tree(Pfangjianzhonglei pRST_temp);/*Qsort*/void Qsort(void * * array,int low,int high,int (*Comp)(void * ,void * );/*快速排序法排序,基于比较*/Buf Buf_Room;/*调试信息*/#define DEBUG #define DEBUG2 #define DEBUG3(x) DEBUG#endifint Buf_Clear(void)Buf_Room.Bufsize=0;return 0;i

23、nt Buf_Fill_Tree(Pfangjianzhonglei pHead)Pfangjian pRoom;for(pRoom=pHead->first;pRoom;pRoom=pRoom->next)Buf_Room.BufferBuf_Room.Bufsize+=pRoom;return 0;int huodekefangzhonglei(FILE * pf,Pfangjianzhonglei sub_tree)if(!feof(pf)fread(sub_tree,sizeof(fangjianzhonglei),1,pf);if(!feof(pf)return 1;el

24、sereturn 0;int huodekefang(FILE * pf,Pfangjian room)if(!feof(pf)fread(room,sizeof(fangjian),1,pf);if(!feof(pf)return 1;elsereturn 0;int huodekehu(FILE * pf,Pkehu custom)if(!feof(pf)fread(custom,sizeof(custom),1,pf);if(!feof(pf)return 1;elsereturn 0;int xierukefang(FILE * pf,Pfangjianzhonglei sub_tre

25、e)return fwrite(sub_tree,sizeof(fangjianzhonglei),1,pf);int xierukefangxinxi(FILE * pf,Pfangjian room)return fwrite(room,sizeof(fangjian),1,pf);int xierukehuxinxi(FILE * pf,Pkehu custom)return fwrite(custom,sizeof(kehu),1,pf);int tianjiazhonglei(Pfangjianzhonglei pRST)char * szTitles="How many

26、Rooms?"int i,num;Pfangjianzhonglei pRST2;for(i=0;pRST;pRST=pRST->next,i+)pRST2=pRST;pRST2->next=(Pfangjianzhonglei)malloc(sizeof(fangjianzhonglei);pRST=pRST2->next;printf("%s",szTitles);scanf("%d",&num);huodenkefang(pRST,num);pRST->zhonglei=i+'0'pRST-

27、>next=NULL;return 0;#define IR_X 100#define IR_Y 100#define IR_CX 100#define IR_C 20int tianjiakefang(Pfangjianzhonglei pRST)const char * szRoom="What is the type?"char BufBUFSIZE;int num,i;Pfangjianzhonglei pRST2;PfangjianpRF;Buf0='0'printf("%s",szRoom);scanf("%d

28、",&num);for(i=1,pRST2=pRST;i<num&&pRST2;pRST2=pRST2->next,i+);if(!pRST2)return 0;pRF=pRST2->first;pRST2->shuliang+;while(pRF->next)pRF=pRF->next;pRF->next=(Pfangjian)malloc(sizeof(fangjian);pRF=pRF->next;huodekefangxinxi(pRF);pRF->next=NULL;return 0;#defin

29、e IC_Y 160#define IC_Y2 220int tianjiakehu(Pfangjianzhonglei pRST)const char * szTree="What is the type?"const char * szRoom="Which room"const char * szName="The name"char RoomBUFSIZE;int type,i;Pfangjianzhonglei pRST2;PfangjianpRF;Pkehu pCu;printf("%s",szTree

30、);scanf("%d",&type);printf("%s",szRoom);scanf("%s",Room);for(i=1,pRST2=pRST;pRST2->zhonglei!=type+'0'pRST2=pRST2->next,i+);if(!pRST2)return 0;pRF=pRST2->first;while(!strcmp(pRF->num,Room)&&pRF)pRF=pRF->next;if(!pRF)return 0;pCu=pRF->

31、;Record;while(pCu->next)pCu=pCu->next;pCu->next=(Pkehu)malloc(sizeof(kehu);pCu=pCu->next;pCu->next=NULL;pRF->times+;huodekehuxinxi(pCu);return 0;int sousuokefangzhonglei(Pfangjianzhonglei pRST)const char * szTree="Which type?"const char * szError="Can't find the

32、Type"char BufBUFSIZE;int type;Buf0='0'printf("%s",szTree);scanf("%d",&type);while(pRST)if(pRST->zhonglei=type+'0')Buf_Clear();Buf_Fill_Tree(pRST);Display();return 1;pRST=pRST->next;getch();return 0;int sousuokefangxinxi(Pfangjianzhonglei pRST)const

33、char * szTree="Which type?"const char * szRoom="Please input the doorplate"const char * szError="Can't find the Type","Can't find the Room"char Buf2BUFSIZE;int type,room;Pfangjian pRF;printf("%s",szTree);scanf("%d",&type);printf

34、("%s",szRoom);scanf("%d",&room);while(pRST)if(pRST->zhonglei=type+'0')pRF=pRST->first;while(pRF)if(!strcmp(pRF->num,Buf2)zhanxiankefang(pRF);return 1;/*if*/pRF=pRF->next;/*while*/printf("%sn",szError1);return 0;/*if*/pRST=pRST->next;/*while*/p

35、rintf("%sn",szError0);getch();return 0;int sousuokehu(Pfangjianzhonglei pRST)const char * szName="The name?"const char * szError="Can't find the one"char BufBUFSIZE;Pfangjian pRF;Pkehu pCu;Buf0='0'printf("%s",szName);scanf("%s",Buf);while

36、(pRST)pRF=pRST->first;while(pRF)pCu=pRF->Record;while(pCu)if(!strcmp(pCu->name,Buf)zhanxiankehu(pCu);return 0;else pCu=pCu->next;pRF=pRF->next;/*while*/pRST=pRST->next;/*while*/printf("%s",szName);getch();return 0;int shanchuzhonglei(Pfangjianzhonglei * pRST)const char *

37、szTree="Which type?"const char * szError="Can't find the Type"char BufBUFSIZE;Pfangjianzhonglei pRST2,pRST3;int type;Buf0='0'printf("%s",szTree);scanf("%d",&type);pRST2=(*pRST);if(pRST2->zhonglei=type+'0')(*pRST)=pRST2->next;free(

38、pRST2);return 0;/*改变头指针*/pRST3=pRST2->next;while(pRST3)if(pRST3->zhonglei=type+'0')pRST2->next=pRST3->next;free(pRST3);/*删去pRST3*/return 1;printf("%s",szError);getch();return 0;int shanchukefang(Pfangjianzhonglei * pRST_head)const char * szTree="Which type?"co

39、nst char * szRoom="Please input the doorplate"const char * szError="Can't find the Type","Can't find the Room"char BufBUFSIZE;Pfangjian pRF,pRF2;Pfangjianzhonglei pRST;int type;pRST=(*pRST_head);Buf0='0'printf("%s",szTree);scanf("%d",

40、&type);printf("%s",szRoom);scanf("%s",Buf);while(pRST)if(pRST->zhonglei=type+'0')pRF=pRST->first;if(!strcmp(pRF->num,Buf)pRST->first=pRF->next;pRST->shuliang-;free(pRF);return 0;pRF2=pRF;pRF=pRF->next;while(pRF)if(!strcmp(pRF->num,Buf)pRF2->

41、next=pRF->next;free(pRF);pRST->shuliang-;return 1;/*if*/pRF2=pRF;pRF=pRF->next;/*while*/printf("%s",szError1);return 0;/*if*/pRST=pRST->next;/*while*/printf("%s",szError0);getch();return 0;int shanchukehu(Pfangjianzhonglei * pRST_head)const char * szName="The nam

42、e?"const char * szError="Can't find the one"char BufBUFSIZE;Pfangjian pRF;Pkehu pCu,pCu2;Pfangjianzhonglei pRST;pRST=(*pRST_head);Buf0='0'printf("%s",szName);scanf("%s",Buf);while(pRST)pRF=pRST->first;while(pRF)pCu=pRF->Record;if(!strcmp(pCu->n

43、ame,Buf)pRF->Record=pCu->next;free(pCu);return 0;pCu2=pCu;pCu=pCu->next;while(pCu)if(!strcmp(pCu->name,Buf)pCu2->next=pCu->next;free(pCu);return 0;/*if*/pCu2=pCu;pCu=pCu->next;pRF=pRF->next;/*while*/pRST=pRST->next;/*while*/getch();return 0;int xiugaikefangzhonglei(Pfangji

44、anzhonglei pRST)const char * szTree="Which type?"const char * szRoom="Please input the doorplate"const char * szError="Can't find the Type","Can't find the Room"char BufBUFSIZE;Pfangjian pRF;int type;Buf0='0'printf("%s",szTree);scanf(

45、"%d",&type);printf("%s",szRoom);scanf("%s",Buf);while(pRST)if(pRST->zhonglei=type+'0')pRF=pRST->first;while(pRF)if(!strcmp(pRF->num,Buf)xiugaikefangxinxi(pRF);return 1;/*if*/pRF=pRF->next;/*while*/printf("%s",szError1);return 0;/*if*/pR

46、ST=pRST->next;/*while*/printf("%s",szError0);getch();return 0;int xiugaikehu(Pfangjianzhonglei pRST)const char * szName="The name?"const char * szError="Can't find the one"char BufBUFSIZE;Pfangjian pRF;Pkehu pCu;Buf0='0'printf("%s",szName);scanf

47、("%s",Buf);while(pRST)pRF=pRST->first;while(pRF)pCu=pRF->Record;while(pCu)if(!strcmp(pCu->name,Buf)xiugaikehuxinxi(pCu);return 0;else pCu=pCu->next;pRF=pRF->next;/*while*/pRST=pRST->next;/*while*/printf("%s",szError);getch();return 0;#define GF_TITLES 8int huode

48、kehuxinxi(Pkehu pCu)int i;char * TempGF_TITLES;char * szCustom="the name","sex","ID","telephone","arrearage","money paid","receiver","time"for(i=0;i<GF_TITLES;i+)Tempi=(char *)malloc(sizeof(char)*BUFSIZE);Get_Info(szC

49、ustom,Temp,GF_TITLES);strcpy(pCu->name,Temp0);pCu->sex=Temp10;strcpy(pCu->id,Temp2);strcpy(pCu->telephone,Temp3);pCu->yingshou=(float)atof(Temp4);pCu->shishou=(float)atof(Temp5);strcpy(pCu->shouyinyuan,Temp6);strcpy(pCu->time,Temp7);for(i=0;i<GF_TITLES;i+)free(Tempi);retur

50、n 0;int huodekefangkehu(Pfangjian pRF,int num)/*获取一个房间的客户记录*/char * szTitles="the ","th Custom"int i;Pkehu pCu,pCu2;pRF->Record=(Pkehu)malloc(sizeof(kehu);for(i=1,pCu=pRF->Record;i<=num&&pCu;i+)printf("%s%d%sn",szTitles0,i,szTitles1);huodekehuxinxi(pCu)

51、;strcpy(pCu->room,pRF->num);getch();pCu->next=(Pkehu)malloc(sizeof(kehu);pCu2=pCu;pCu=pCu->next;free(pCu);pCu2->next=NULL;return 0;#define GR_TITLES 3int huodekefangxinxi(Pfangjian pRF)int i;char *TempGR_TITLES;char * szRooms="the doorplate","How many Customs?",&qu

52、ot;the Price"for(i=0;i<GR_TITLES;i+)Tempi=(char *)malloc(sizeof(char)*BUFSIZE);Tempi0='0'Get_Info(szRooms,Temp,GR_TITLES);strcpy(pRF->num,Temp0);pRF->times=atoi(Temp1);pRF->jiage=(float)atof(Temp2);huodekefangkehu(pRF,pRF->times);for(i=0;i<GR_TITLES;i+)free(Tempi);retu

53、rn 0;int huodenkefang(Pfangjianzhonglei sub_tree,int num_room)int i;const char * szTitles="the ","th room"char bufferBUFSIZE;Pfangjian pRF,pRF2;sub_tree->first=(Pfangjian)malloc(sizeof(fangjian);for(i=1,pRF=sub_tree->first;i<=num_room;i+)sprintf(buffer,"%s%d%s",szTitles0,i,szTitles1);printf("%sn",buffer);getch();huodekefangxinxi(pRF);pRF->zhonglei=sub_tree->zhonglei;pR

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论