文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > IT/计算机 > 计算机软件及应用 > 数据结构与算法课设源代码——简易客房管理系统
侵权投诉

数据结构与算法课设源代码——简易客房管理系统

1.具有建立数据文件(客房信息文件、住客信息文件)功能; 2.具有数据输入功能; 3.具有数据修改功能; 4.具有数据删除功能; 5.能查询(查找)一些基本信息(如按房号查询、按姓名查询、空余客房查询等); 6.具有多种统计功能(要求有一定的实用性) (如某客房当前有那些空床、某住客应付多少费用、某天住店总人数和总收入等) 7.能具有排序功能(比如在查询所有的客房信息时,能根据房间价格进行排序,方便客人挑选房间

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
//#include <windows.h>

struct Room ;
struct Customer ;
typedef struct Room * Proom;
typedef struct Customer * Pcustomer;

struct Room
{
int RoomNumber;//房号
int RoomType;//房型
int Price;//单价(每床)
int Number; //已住人数
Proom next;
};

struct Customer
{
char name[10],ID[19]; //顾客姓名,顾客身份证号
char sex[5];//性别
int age;//年龄
int state;//房型
int room_number;//房号
int check_in_date;//入住日期
int departure_date ;//离店日期
Pcustomer next;
};

Proom head_room = NULL;
Pcustomer head_customer = NULL;
Proom r_room = NULL; //房间链表尾指针
Pcustomer r_customer = NULL;//顾客链表尾指针

Proom update_room_add(int room_num);

bool read_room() //读取room文件来创建链表
{
FILE *filep;
if((filep = fopen("d://Room.txt","a+")) == NULL)
{
printf("文件打开失败!");
getch();
return 0;
}
Proom temp_node = NULL;
temp_node = (Proom)malloc(sizeof(struct Room));
temp_node->next = NULL;
head_room = r_room = temp_node;
while(true)
{
if(feof(filep)||fread(temp_node,sizeof(struct Room),1,filep)!=1)
{
free(temp_node);
if (temp_node == head_room)
head_room = r_room = NULL;
else
r_room->next = NULL;
break;
}
r_room->next = temp_node;
r_room = r_room->next;
temp_node = (Proom)malloc(sizeof(struct Room));
temp_node->next = NULL;
}
return 1;
}

bool write_room() //保存room链表(即房间信息)到room文件
{
FILE *filep;
if((filep = fopen("d://Room.txt","w+")) == NULL)
{
printf("文件打开失败!");
getch();
return 0;
}
Proom temp_node = head_room;
while( temp_node != NULL )
{
fwrite(temp_node,sizeof(struct Room),1,filep);
temp_node = temp_node->next;
}
fclose(filep);
return 1;
}

bool read_customer()//读取customer文件来创建customer链表
{
FILE *fileq;
if((fileq = fopen("d://Customer.txt","a+")) == NULL)
{
printf("文件打开失败!");
getch();
return 0;
}
Pcustomer temp_node = (Pcustomer)malloc(sizeof(struct Customer));
head_customer = r_customer = temp_node;
while(true)
{
if(feof(fileq)||fread(temp_node,sizeof(struct Customer),1,fileq)!=1)
{
free(temp_node);
if (temp_node == head_customer)
head_customer = r_customer = NULL;
else
r_customer->next = NULL;
break;
}
r_customer->next = temp_node;
r_customer = r_customer->next;
temp_node = (Pcustomer)malloc(sizeof(struct Customer));
temp_node->next = NULL;
}
fclose(fileq);
return 1;
}

bool write_customer()//保存customer链表信息到customer文件
{
FILE *filep;
if((filep = fopen("d://Customer.txt","w+")) == NULL)
{
printf("文件打开失败!");
getch();
return 0;
}
Pcustomer temp_node = head_customer;
while( temp_node != NULL )
{

第1页

你可能喜欢

  • 数据结构学生信息管理系统
  • C语言图书管理系统课程设计
  • c学生成绩管理系统课程设计
  • 信息系统管理办法
  • 02382管理信息系统
  • 数据结构停车场管理
  • 学生管理系统详细设计
  • C++银行管理系统

热门文档

相关文档

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email