#include <stdio.h>
#include <stdlib.h>
// 定义房间结构体
typedef struct Room {
int roomNumber; //房间号
int capacity; //容量
int isAvailable; //可用性
struct Room* next; //指向下一个房间的指针
} Room;
Room* head = NULL; //定义头指针
// 创建新房间的函数
Room* createRoom(int roomNumber, int capacity, int isAvailable) {
Room* newRoom = (Room*)malloc(sizeof(Room)); //为新房间分配内存
if (newRoom == NULL) {
printf("内存分配失败。房间未创建。\n");
return NULL;
}
newRoom->roomNumber = roomNumber; //设置房间号
newRoom->capacity = capacity; //设置容量
newRoom->isAvailable = isAvailable;//设置可用性
newRoom->next = NULL; //设置下一个房间指针为NULL
return newRoom; //返回新创建的房间
}
// 添加房间到链表的函数
void addRoom(int roomNumber, int capacity, int isAvailable) {