C语言课程设计-宾馆客房管理系统.docx
C语言课程设计-宾馆客房管理系统 宾馆客房管理系统课程设计报告 题目宾馆客房管理系统 学号 姓名 同组成员 年级专业09级电子信息工程(2)班 指导教师 完成日期2022 年06 月20 日 报告目录 1.课题要求 2.课题分析 3.成员分工 4.程序流程图 5.程序代码及调试 6.小节及收获体会 7. 参考书籍: 一、课题要求: 某宾馆有301、302、303、304、305五个标准间,每个标准间可住2人; 链表存储结构:姓名、性别、房号、后续指针,按房间号有序; 能实现入住(注意性别)和退房,能按给定姓名、房号查询; 建议采用链表结构,但用其它方法实现也可。 二、课题分析: 本程序是针对宾馆客房管理所设计的系统软件。我们借助C语言作为编写工具,以TurboC作为编译环境,以静态链表作为编写方法,通过对系统库函数的选择调用以及对所写函数的有机整合,辅之以规整的页面设计,从而完成课题内容的程序设计部分。 程序中我们定义了一个结构体struct hotel,用它来存储用户信息,并以他为操作对象实现其他功能。结构体中包括用户的姓名、性别、(均为包含两个元素的一位字符数组)房号及后续指针。 程序中含有定义函数如下: Message、main、choice、live_in(包含live_in_one、live_in_two)、live_away、check_through。 主函数实现对choice、live_in、live_away、check_through的声明以及选择性调用。Choice是界面输出函数,Message是住房信息输出函数,live-in、live_away、check_through分别是入住、退房、 查询函数。live_in可实现单人入住和双人入住的双重选择,check_through可满足按姓名和房号查询的两种方式。通过对程序的相应操作可以基本实现课题要求。 三、成员分工: 袁家文负责Message、main、Choice函数,夏楠负责Live_in、Live in _one和Live in_two函数,我负责Live_away、Look_through 函数。 四、程序流程图: 五、程序代码及调试: (1)代码: #include #include #include #define NULL 0 struct hotel int num; char name220; char sex2; struct hotel *next; ; void message(struct hotel *p1) textcolor(8); clrscr(); gotoxy(8,5); printf(" *n"); gotoxy(8,6); printf(" WELCOME TO OUR HOTELn"); gotoxy(8,7); printf(" *n"); gotoxy(8,8); printf(" * roomnum name1 sex1 name2 sex2 n"); gotoxy(8,10); printf(" * %d %s %c %s %c n",p1->num,p1->name0,p1->sex0,p1->name1,p1->sex1); p1=p1->next; gotoxy(8,12); printf(" * %d %s %c %s %c n",p1->num,p1->name0,p1->sex0,p1->name1,p1->sex1); p1=p1->next; gotoxy(8,14); printf(" * %d %s %c %s %c n",p1->num,p1->name0,p1->sex0,p1->name1,p1->sex1); p1=p1->next; gotoxy(8,16); printf(" * %d %s %c %s %c n",p1->num,p1->name0,p1->sex0,p1->name1,p1->sex1); p1=p1->next; gotoxy(8,18); printf(" * %d %s %c %s %c n",p1->num,p1->name0,p1->sex0,p1->name1,p1->sex1); gotoxy(8,20); printf(" *n"); void main() void choice(struct hotel *p2); void live_in(struct hotel *p3); void live_away(struct hotel *p4); void check_through(struct hotel *p5); struct hotel *p,*head,a,b,c,d,e; int i; a.num=301; b.num=302; c.num=303; d.num=304; e.num=305; 00= 10= 00= 10= 00= 1 0= 00= 10= 00= 10='0' a.sex0=a.sex1= b.sex0=b.sex1= c.sex0=c.sex1= d.sex0=d.sex1= e.s ex0=e.sex1=' ' head=&a; a.next=&b; b.next=&c; c.next=&d; d.next=&e; e.next=NULL; p=head; choice(p); void choice(struct hotel *p2) struct hotel *pt; int x; textcolor(5); clrscr(); gotoxy(10,5); printf(" *n"); gotoxy(10,7); printf(" * 1.To Live In n"); gotoxy(10,9); printf(" * 2.To Live Awway n"); gotoxy(10,11); printf(" * 3.To Look Through n"); gotoxy(10,13); printf(" Please Insert The Number To Choose The Sevicen"); gotoxy(10,15); printf(" *n"); scanf("%d",&x); switch(x) case 1:live_in(p2);break; case 2:live_away(p2);break; case 3:check_through(p2);break; void live_in(struct hotel *p3) void live_in_two(struct hotel *p3_1); void live_in_one(struct hotel *p3_2); struct hotel *pt; int x,m; char str20,ch,str120,ch1;clrscr(); textcolor(4); pt=p3; while(1) printf(" Are you contiune to live in?n 1.YESn 2.NOn"); scanf("%d",&m); switch(m) case 1: printf(" Choose The Room That You Want To Live Inn"); scanf("%d",&x); if(x>300&&xnum!=x) pt=pt->next; if(pt->sex0=' '|pt->sex1=' ') if(pt->sex0=' '&&pt->sex1=' ') live_in_two(pt);message(p3); else live_in_one(pt);message(p3); else printf("The room is fulln"); else printf("PLEASE ENTER THE RIGHT NUMBER FROM 301 TO 305");break; case 2:choice(p3);break; void live_in_two(struct hotel *p3_1) struct hotel *pt; int x; char str20,ch,str120,ch1;clrscr(); textcolor(4);pt=p3_1; gotoxy(10,7); printf(" IT ALLOWS TWO PEOPLE TO LIVE INn"); gotoxy(10,9); printf(" *1.Two People Live In n"); gotoxy(10,10); printf( " *2.One People Lives Inn"); gotoxy(10,12); printf(" *3.returnn"); printf(" Inset The Number To Make Your Chiocen"); scanf("%d",&x); switch(x) case 1:gotoxy(10,14); printf(" *please give the message of the two customersn"); gotoxy(10,16); printf(" *1.one customer's name and sexn:"); scanf("%s",&str); scanf("%c",&ch); ch=getchar(); gotoxy(10,18); printf(" *2.the other's name and sex:n"); scanf("%s",&str1);scanf("%c",&ch1);ch1=getchar(); strcpy(pt->name0,str);pt->sex0=ch; strcpy(pt->name1,str1);pt->sex1=ch1;break; case 2: gotoxy(10,20); printf(" *please give the name and sex:n"); scanf("%s",&str);scanf("%c",&ch);ch=getchar(); strcpy(pt->name0,str);pt->sex0=ch; break; case 3:choice(p3_1);break; void live_in_one(struct hotel *p3_2) struct hotel *pt; int x; char str20,ch;clrscr(); pt=p3_2;textcolor(4); printf(" IT ONLY ALLOWS ONE PERSON TO LIVE IN.nDO YOU WANT TO CONTINUE?n"); gotoxy(10,7); printf(" *1.LIVE IN n"); printf(" *2.REBACKn"); scanf("%d",&x); switch(x) gotoxy(10,9); case 1: gotoxy(10,11); printf(" please give the name and sex:n"); scanf("%s",&str); scanf("%c",&ch); ch=getchar(); if(pt->sex0=' ') strcpy(pt->name0,str); pt->sex0=ch; else strcpy(pt->name1,str); pt->sex1=ch;break; case 2:choice(p3_2);break; void live_away(struct hotel *p4) struct hotel *pt; 安徽师范大学物理与电子信息学院- 10 int x,i,m; char str20; textcolor(2); clrscr(); pt=p4; while(1) printf(" Are you contiune to live away?n 1.YESn 2.NOn"); scanf("%d",&m); switch(m) case 1: printf(" What The Room That You Live In?:n"); scanf("%d",&x); if(x>300&&xnum!=x) pt=pt->next; printf(" GIVE YOUR NAME:n"); scanf("%s",&str); for(i=0;inamei,str)=0) pt->namei0='0'pt->sexi=' 'message(p4); else choice(p4); printf(" YOUR NAME CANN'T BE FOUND IN THIS ROOMn"); else choice(p4); printf(" PLEASE GIVE THE RIGHT NUMBERn"); break; case 2: choice(p4);break; 安徽师范大学物理与电子信息学院- 11