(1)要求实现旅客的入住、换房和退房、查看旅客和房间信息,以及从文件读取相关信息,将相关信息储存到文件的功能,从而实现旅馆信息管理的基本功能。
(2)可以采用两个结构体分别存储旅客和房间的信息。
(3)使用结构体数组来实现旅客入住、换房、退房三种行为。
(4)能将文件中的信息读到结构体中,能将结构体的信息保存到文件中。
🐧848 604 283 一起交流 全天在线
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//定义旅客结构体
struct Customer
{
char name[20]; //姓名
int id; //身份证号
int room; //房间号
int time; //住宿时间
};
//定义房间结构体
struct Room
{
int id; //房间号
int type; //房间类型
int price; //房间价格
int status; //房间状态(0:未入住,1:已入住)
};
//函数声明
void checkIn(struct Customer[], struct Room[], int, int); //旅客入住
void changeRoom(struct Customer[], struct Room[], int, int); //旅客换房
void checkOut(struct Customer[], struct