Traditional Culture Encyclopedia - Travel guide - Tourism management system

Tourism management system

# Define NULL 0

# Define LEN sizeof (structured customer)

# contains "string.h"

Structured customer

{

int num

char name[20];

Long date;

Structured customers * Next step;

} cus

Construct customer * create (void)/* create a linked list */

{

Structure customer * header, *p 1, * p2

int n = 0;

P 1= (structural customer *) malloc (len);

P2= (structural customer *) malloc (len);

Printf ("Please enter customer information: \ n");

printf(" \ n room:");

scanf("%d ",& ampp 1->; num);

printf(" \ n ");

printf(" name:");

scanf("%s ",p 1->; Name);

printf(" \ n ");

Printf ("check-in time:");

scanf("%ld ",& ampp 1->; Date);

printf(" \ n ");

head = NULL

while(p 1->; num! =0)

{

n++;

If (n== 1)

head = p 1;

other

p2->; next = p 1;

p2 = p 1;

P 1= (structural customer *) malloc (len);

Printf ("Please enter customer information: \ n");

printf(" \ n room:");

scanf("%d ",& ampp 1->; num);

printf(" \ n ");

printf(" name:");

scanf("%s ",p 1->; Name);

printf(" \ n ");

Printf ("check-in time:");

scanf("%ld ",& ampp 1->; Date);

printf(" \ n ");

}

p2->; next = NULL

Return (head);

}

Structure customer * insert (structure customer * head, structure customer * consumer)/* Register new customer information */

{

Structure customer *p 1, * p2

P 1 = head;

P2 = consumer;

if(p 1->; Au Suivant! = empty)

p 1 = p 1->; Next;

if(p 1->; next==NULL)

{

p 1->; next = p2

p2->; next = NULL

}

Return (head);

}

Struct customer * del (struct customer * head, int num)/* displays the information of the checkout customer */

{

Structure customer *p 1, * p2

if(head==NULL)

{

Printf ("No customer information \ n");

Return (head);

}

P 1 = head;

And (num! = p 1->; Number & AMPP1->; Au Suivant! = empty)

{

p2 = p 1; p 1 = p 1->; Next;

}

if(num = = p 1->; Numbers)

{

if(p 1==head)

head = p 1->; Next;

other

p2->; next = p 1->; Next;

Printf ("Check-out customer information: \ n");

Printf ("Guest Room:% d \ n",&; p 1->; num);

Printf ("name: %s\n ",p 1-& gt; Name);

Printf ("check-in time:% ld \ n",&; p 1->; Date);

}

other

Printf ("No information about this customer \ n");

Return (head);

}

Struct customer * search (struct customer * head, char c _ name [])/* Query customer information */

{

Structural customer * p;;

P = head;

while(strcmp(p-& gt; Name, c_name) and amp&->; Au Suivant! = empty)

p = p-& gt; Next;

If (p->; name==c_name)

{

Printf ("Customer's information is: \ n");

Printf ("Room:% d \ Name:% s \ Registration time: %ld", p-> Num, p- > name, p-> Date);

}

If (p->; Name! = c _ name & amp& ampp->; next==NULL)

Printf ("There is no information about this customer! \ n ");

}

Voidprint (struct customer * head)/* Print customer information */

{

Structural customer * p;;

Printf ("\ nExisting customer information is: \ n");

P = head;

If (head! = empty)

do

{

Printf ("Guest Room: %d\n", p-> num);

Printf ("name: %s\n ",p-& gt; Name);

Printf ("Registration time: %ld\n", p-> Date);

p = p-& gt; Next;

}while(p! = NULL);

}

Master ()

{

Structure customer * head, * p;;

Int m, number;

char c _ name[20];

printf(" \ n ");

Printf ("Made in Chen Hongkai \ n \ n");

printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");

Printf ("Welcome to Tourism Information Management System \ n");

printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n ");

printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n \ n ");

Printf(" 1: build database \ n ");

printf(" 2:registration \ n ");

Printf(" 3: check out \ n ");

printf(" 4:query \ n ");

printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n \ n ");

Printf ("Please do something: \ n");

scanf("%d ",& ampm);

If (m== 1)

head = creat();

other

If (m==2)

{

Printf ("Please enter the customer information to be registered:");

P= (structural customer *) malloc (len);

scanf("%d %s %ld ",& ampp->; Num, p- > name & amp->; Date);

head=insert(head,p);

Print (header);

}

other

If (m==3)

{

Printf ("Please enter the check-out room number of the customer:");

Scanf("%d ",&);

Head=del (head, number);

Print (header);

}

other

If (m==4)

{

Printf ("Please enter the customer name to query:");

scanf("%s ",c _ name);

Search (head, c _ name);

}

other

Printf ("Error in executing operation!" );

}