Traditional Culture Encyclopedia - Hotel accommodation - Hotel management system (C language)
Hotel management system (C language)
# include & ltstdlib.h & gt
# include & ltstring.h & gt
Structure Customer _ Node {
char id[ 18];
Int days;
int money
Char room number [3];
struct customers _ node * next
};
Struct customers_node * p0, * header;
//# Definition N 100
struct customers _ node * Create _ Cust _ Doc(); //New
struct customers _ node * insert doc(struct customers _ node * head,char id[]); //Insert
struct customers _ node * delete doc(struct customers _ node * head,char id[]); //Delete
struct customers _ node * search doc(struct customers _ node * head,char id[]); //query
void Print _ Cust _ Doc(struct customers _ node * head); //Call the information function
Structural Customer _ Node * Customer (Structural Customer _ Node * P0); //Do you need to allocate dynamic storage space for p0?
int main(void)
{
struct customers _ node * head
Int selection;
char id[ 18];
Do {
Printf ("This system function: \ n");
Printf(" 1。 Create 2. Search 3. Insert 4. delete 5 . print 0:Exit \ n ");
Printf ("Please select:");
Scanf("%d ",& select);
Switch (Select) {
Case 1:
head = Create _ Cust _ Doc();
Break;
Case 2:
Printf ("Please enter your ID number: \ n");
scanf("%s ",id);
head=searchDoc(head,id);
Break;
Case 3:
Printf ("Please enter your ID number: \ n");
scanf("%s ",id);
head=InsertDoc(head,id);
Break;
Case 4:
Printf ("Please enter your ID number: \ n");
scanf("%s ",id);
head=DeleteDoc(head,id);
Break;
Case 5:
Print_Cust_Doc (header);
Break;
Case 0:
Break;
}
}while (choose! =0);
Returns 0;
}
Structural Customer _ Node * Customer (Structural Customer _ Node * p0)
{
Structure customers _ node * p;;
Int days, money, choice, z;
char id[ 18];
Char room number [3];
Printf ("Please enter your ID number: \ n");
scanf("%s ",id);
Printf ("You have successfully logged in! \ n ");
Printf ("Please select room type: \ n");
Printf(" 1。 Single room/night 150 yuan \n 2. Double room/night in 200 yuan \n 3. Standard Room/Night 300 yuan \n 4. Presidential Suite/Night 600 yuan \ n ");
Scanf("%d ",& select);
Switch (Select) {
Case 1:printf ("Please enter the scheduled number of days \ n");
Scanf("%d ",& days);
Money = days *150;
Printf ("please pay %d yuan in advance \n", money);
Printf(" 1。 Ok (reservation successful) 2. Return (whether to reschedule) \ n ");
scanf("%d ",& ampz);
if(z== 1){
Printf ("You have made a reservation successfully ★ The room number is");
scanf("%s ",room number);
} broken;
Scenario 2:printf ("Please enter a predetermined number of days \ n");
Scanf("%d ",& days);
Money = days * 200;
Printf ("please pay %d yuan in advance \n", money);
Printf(" 1。 Ok (reservation successful) 2. Return (whether to reschedule) \ n ");
scanf("%d ",& ampz);
if(z== 1){
Printf ("You have made a reservation successfully ★ The room number is");
scanf("%s ",room number);
} broken;
Case 3: printf ("Please enter the scheduled number of days:");
Scanf("%d ",& days);
Money = days * 300;
Printf ("please pay %d yuan in advance \n", money);
Printf(" 1。 Ok (reservation successful) 2. Return (whether to reschedule) \ n ");
scanf("%d ",& ampz);
if(z== 1){
Printf ("You have made a reservation successfully ★ The room number is");
scanf("%s ",room number);
} broken;
Scenario 4:printf ("Please enter a predetermined number of days \ n");
Scanf("%d ",& days);
Money = days * 600;
Printf ("please pay %d yuan in advance \n", money);
Printf(" 1。 Ok (reservation successful) 2. Return (whether to reschedule) \ n ");
scanf(" %d ",& ampz);
if(z== 1){
Printf ("You have made a reservation successfully ★ The room number is");
scanf("%s ",room number);
} broken;
Default: printf ("Your input is wrong, please try again, thank you. \ n ");
Break;
P= (structured customer _ node *)malloc(sizeof)); //Can the transfer of structural elements be completed with pointers?
strcpy(p-& gt; id,id);
strcpy(p-& gt; roomnumber,room number);
p->; Days = days;
p->; Money = money;
Return p;
}
structural customers _ node * create _ cust _ doc()//New
{
Structure customers_node * head, * p;;
int size = size of(struct customers _ node);
p =(struct customers _ node *)malloc(size);
head->; next = NULL
Customer (* P0); //Call the function
//p = P0;
head->; next = p;
Return head;
}
struct customers _ node * insert doc(struct customers _ node * head);
{
Structure customers_node *q, * temp
Q= (structured customer _ node *)malloc(sizeof);
Customer (P0);
Temp = p0// Unresolved element insertion
q = head-& gt; Next;
if(head-& gt; next==NULL){
Q = temperature;
q->; next = NULL
}
while(q->; Next) q = q-& gt;; Next;
q->; next = temp
Return head;
}
Struct customers _ node * searchdoc (struct customers _ node * head, charid)// Can I return all the elements in the structure by using id only?
{
struct customers _ node * p = head-& gt; Next;
p = head-& gt; Next;
if(head-& gt; next==null)
Printf ("unoccupied");
Otherwise {
while(strcmp(id,p-& gt; id)! =0) // How to only use id to represent the data part in the node (structure) p = p-& gt;; Next;
p = p-& gt; Next;
}
Return p;
}
struct customers _ node * delete doc(struct customers _ node * head,char id)
{
Structure customer _ node * p, * q;;
p = head-& gt; Next;
q = p->; Next;
if(p==null)
Returns null
And (p! =null){
if(strcmp(id,p-& gt; id)==0){
q = p;
Free (p);
}
p = p-& gt; Next;
q = p->; Next;
}
Return head;
}
void Print _ Cust _ Doc(struct customers _ node * head)
{
Structure customers _ node * q;;
if(head-& gt; next==null){
Printf ("\ nNo record \ n");
Return;
}
Printf ("Check-in customer record: \ n");
for(q = head-& gt; Next; q; q = q-& gt; Next) {
Printf ("ID number: %s\t ",q-> id);
Printf ("registration days: %d\t", q-> Day);
Printf ("advance payment: %d\t", q-> Money);
Printf ("room number: %s\n", q-> room number);
}
}
- Related articles
- How to get to Jiangdong Bus Terminal from Yiwu Commodity City, Zhejiang Province? Which bus can I take?
- What about Shanxi Fengze Concrete Engineering Co., Ltd.?
- How to make a speech for excellent hotel staff
- How about Tangshan Labor Technician College?
- How to take a bus from Longkou East Road south to Sherbin Hotel? How soon will it take?
- How far is Quanfeng Express from Shijiazhuang to Xinjiang?
- Does the hotel charge for cable TV?
- Where is Zhaoqing Yudongfang located?
- What is the word of Zangneng Group?
- How far is it from Zhongshan, Guangdong to Zaozhuang, Shandong?