旅游管理系统

发布时间:2024-05-10 19:45 发布:上海旅游网

问题描述:

课题:用C语言开发一个简单的“旅游管理系统”
实现功能需求:
客户登记客房
客户退房
客户情况查询
客户配置管理
1. 设计要求
系统以菜单方式工作(文本菜单或图形菜单)
输入数据模块,数据用文件保存
输出数据模块,数据用文件保存
基本算法运用模块(排序、查找、插入、比较算法中至少包含一种)
系统进入画面(静态或动态)
系统其他功能实现(任选)
最好能够形成多文件结构,将函数的声明、宏定义等放置在一个文件中
2、版式要求
设计版面清晰,结构明确
有明确的文件说明
有详细的注释和说明
整体上符合附录编码规范中的版式要求

问题解答:

楼上的错误很多,很不完整。

我不会给你编写,但我知道做你这事用Delphi最合适,而不是C,要用C的话,复杂度和工期可能要增加几十倍,界面还用着不舒服——我只是指出你的要求对你的需要而言并不合理,你得自己去做。
这些作业最好还是自己完成对自己比较有利。

#define NULL 0
#define LEN sizeof(struct customer)
#include "string.h"
struct customer
{
int num;
char name[20];
long date;
struct customer *next;
}cus;
struct customer *creat(void) /*建立一个链表*/
{
struct customer *head,*p1,*p2;
int n=0;
p1=(struct customer *)malloc(LEN);
p2=(struct customer *)malloc(LEN);
printf("请输入客户的信息:\n");
printf("\n房间:");
scanf("%d",&p1->num);
printf("\n");
printf("姓名:");
scanf("%s",p1->name);
printf("\n");
printf("入住时间:");
scanf("%ld",&p1->date);
printf("\n");
head=NULL;
while(p1->num!=0)
{
n++;
if(n==1)
head=p1;
else
p2->next=p1;
p2=p1;
p1=(struct customer *)malloc(LEN);
printf("请输入客户的信息:\n");
printf("\n房间:");
scanf("%d",&p1->num);
printf("\n");
printf("姓名:");
scanf("%s",p1->name);
printf("\n");
printf("入住时间:");
scanf("%ld",&p1->date);
printf("\n");
}
p2->next=NULL;
return(head);
}
struct customer *insert(struct customer *head,struct customer *consumer) /*登记新入住的客户的信息*/
{
struct customer *p1,*p2;
p1=head;
p2=consumer;
if(p1->next!=NULL)
p1=p1->next;
if(p1->next==NULL)
{
p1->next=p2;
p2->next=NULL;
}
return(head);
}
struct customer *del(struct customer *head,int num) /*显示退房客户的信息*/
{
struct customer *p1,*p2;
if(head==NULL)
{
printf("没有客户的信息\n");
return(head);
}
p1=head;
while(num!=p1->num&&p1->next!=NULL)
{
p2=p1;p1=p1->next;
}
if(num==p1->num)
{
if(p1==head)
head=p1->next;
else
p2->next=p1->next;
printf("退房客户的信息:\n");
printf("客房:%d\n",&p1->num);
printf("姓名:%s\n",p1->name);
printf("入住时间:%ld\n",&p1->date);
}
else
printf("没有该客户的信息\n");
return(head);
}
struct customer *search(struct customer *head,char c_name[]) /*查询客户信息*/
{
struct customer *p;
p=head;
while(strcmp(p->name,c_name)&&p->next!=NULL)
p=p->next;
if(p->name==c_name)
{
printf("该客户的信息为:\n");
printf("房间:%d\n姓名:%S\n入住时间:%ld",p->num,p->name,p->date);
}
if(p->name!=c_name&&p->next==NULL)
printf("没有该客户的信息!\n");
}
void print(struct customer *head) /*打印出现有客户的信息*/
{
struct customer *p;
printf("\n现有客户信息为:\n");
p=head;
if(head!=NULL)
do
{
printf("客房:%d\n",p->num);
printf("姓名:%s\n",p->name);
printf("入住时间:%ld\n",p->date);
p=p->next;
}while(p!=NULL);
}
main()
{
struct customer *head,*p;
int m,number;
char c_name[20];
printf("\n");
printf(" 制作:陈宏凯\n\n");
printf(" ******************************\n");
printf(" 欢迎进入旅游信息管理系统\n");
printf(" ******************************\n");
printf(" ******************************\n\n");
printf(" 1:建库\n");
printf(" 2:登记\n");
printf(" 3:退房\n");
printf(" 4:查询\n");

printf(" ******************************\n\n");
printf("请执行操作:\n");
scanf("%d",&m);
if(m==1)
head=creat();
else
if(m==2)
{
printf("请输入要登记得客户的信息:");
p=(struct customer *)malloc(LEN);
scanf("%d %s %ld",&p->num,p->name,&p->date);
head=insert(head,p);
print(head);
}
else
if(m==3)
{
printf("请输入要退房的客户的房间号:");
scanf("%d",&number);
head=del(head,number);
print(head);
}

else
if(m==4)
{
printf("请输入要查询的客户的姓名:");
scanf("%s",c_name);
search(head,c_name);
}
else
printf("执行操作错误!");
}

热点新闻