#include<stdio.h> |
#include<stdlib.h> |
#include<time.h> |
#include<string.h> |
struct Customer{ |
char name[10]; //顾客名字 |
char ID[20]; //顾客身份证; |
char sex[5]; //性别 |
int age; //年龄 |
int state; //房型 |
int room_number; //房号 |
int in_data; //入住日期 |
int out_data; //离店日期 |
struct Customer *next; |
}; |
typedef struct Customer * Pcustomer; |
struct Room{ |
int room_num; //房号 |
int state; //房型 |
int price; //价格 |
int condition; //房间状态 |
struct Room *next; |
}; |
typedef struct Room *Proom; |
void displayinformation(Pcustomer head) //显示顾客信息 |
{ |
Pcustomer p; |
printf ( "\n姓名 性别 年龄 身份证 房型(1.单人间2.双人间3.通铺) 房号 入住日期 退房日期 \n" ); |
p=(Pcustomer) malloc ( sizeof ( struct Customer)); |
p=head; |
if (head!=NULL) |
{ |
while (p!=NULL) |
{ |
printf ( "\n" ); |
printf ( "%-s\t%-s\t%-d\t%-s\t" ,p->name,p->sex,p->age,p->ID); |
printf ( "%-d\t%-d\t%-d\t%-d\t" ,p->state,p->room_number,p->in_data,p->out_data); |
p=p->next; |
} |
} |
else |
printf ( "无数据\n" ); |
} |
void print_room(Proom room) //显示客房信息 |
{ |
Proom p; |
printf ( "房号 房型 价格 是否为空房(1.yes 0.no)\n" ); |
p=(Proom) malloc ( sizeof ( struct Room)); |
p=room; |
if (room!=NULL) |
{ |
while (p!=NULL) |
{ |
printf ( "%-d\t%-d\t%-d\t%-d\t\n" ,p->room_num,p->state,p->price,p->condition); |
p=p->next; |
} |
} |
else |
printf ( "无数据\n" ); |
} |
struct Customer *inputinformation(Pcustomer head) //顾客信息录入 |
{ |
struct Customer *Insert(Pcustomer head,Pcustomer p); |
int n,i; |
Pcustomer p; |
p=(Pcustomer) malloc ( sizeof ( struct Customer)); |
printf ( "\n请输入要录入顾客人数:" ); |
scanf ( "%d" ,&n); |
for (i=0;i<n;i++) |
{ |
printf ( "\n请输入姓名:" ); |
scanf ( "%s" ,p->name); |
printf ( "\n请输入性别:" ); |
scanf ( "%s" ,p->sex); |
printf ( "\n请输入年龄:" ); |
scanf ( "%d" ,&p->age); |
printf ( "\n请输入身份证:" ); |
scanf ( "%s" ,p->ID); |
printf ( "\n请输入房型(1.单人间2.双人间3.通铺):" ); |
scanf ( "%d" ,&p->state); |
printf ( "\n请输入房号:" ); |
scanf ( "%d" ,&p->room_number); |
printf ( "\n请输入入住日期(如20160303):" ); |
scanf ( "%d" ,&p->in_data); |
printf ( "\n请输入退房日期(如20160303):" ); |
scanf ( "%d" ,&p->out_data); |
head=Insert(head,p); |
p=(Pcustomer) malloc ( sizeof ( struct Customer)); |
} |
printf ( "\n您输入的顾客信息为:\n" ); |
displayinformation(head); |
return (head); |
} |
初级程序员
by: 行空者 发表于:2022-08-03 17:35:39 顶(0) | 踩(0) 回复
我在学校就做过
你的思路更简洁
回复评论