Joke Collection Website - Bulletin headlines - Kneeling, data structure experiment, making sports lottery number selector and air passenger booking system
Kneeling, data structure experiment, making sports lottery number selector and air passenger booking system
# include & ltstring.h & gt
# include & ltstdlib.h & gt
# Definition number 1000
Structured customer
{ char name[20];
char id[20];
Int number;
} t[N];
Structured air
{ char hangban[ 10];
int num
char start[20];
Char exceeds [20];
Charging time [10];
Int ticket book;
Int floating price;
Shuangpu Zhekou;
} s[N];
int i,j;
int m = 0;
# define print 1 " %- 10s % d % 8s % 1s % 10s % 8d % 10d % 12lf \ n ",s[i]。 Hangban, s[i]. Number, s[i]. Here we go, s[i]. End, s[i]. Time, s[i]. Pu Shu, s[i]. Piaojia, s[i]. Park cheuk-kou
# define print 2 " % 12s % 12s % 8d % 10d \ n ",t[i]。 id,s[i]。 Hangban, s[i]. Number, s[i]. hackberry
void shuru();
void shuchu();
void save();
void read();
void chaxun();
void shanchu();
void ding Piao();
Void refund ();
void main()
{ int j;
do
{ printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n \ n ");
Printf(" * 1。 Enter flight information * \n\n "
"* 2. Browse flight information * \n\n"
"* 3. Query function * \n\n"
"* 4. Delete flight information * \n\n"
"* 5. Reservation function * \n\n"
"* 6. Refund function * \n\n"
"* 0.exit * \ n \ n ");
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n \ n ");
Printf ("Please choose from 0-6, ending with Enter: \ n \ n");
scanf("%d ",& ampj);
Switch (j)
{
Case 1: Shuru ();
Break;
Case 2: Shu Chu ();
Break;
Case 3: Cha Xun ();
Break;
Case 4: Shanchu ();
Break;
Case 5: Booking tickets ();
Break;
Case 6: Refund ();
Break;
Case 0:;
Break;
}
}while(j! =0);
Printf ("Thank you for your use, goodbye! \ n ");
}//End of main function
Void Shuru ()
{
int y;
for(I = 0; I & ltn;; i++)
{
Printf ("Please enter flight number: \ n");
Scanf("%s ",s[i]. Hangban);
Printf ("Please enter the plane number: \ n");
scanf("%d ",& amps[i]。 num);
flush all();
Printf ("Please enter the origin station: \ n");
Scanf("%s ",s[i]. Start);
Printf ("Please enter terminal: \ n");
scanf("%s ",s[i].over);
flush all();
Printf ("Please enter time: \ n");
Scanf("%s ",s[i]. Time);
Printf ("Please enter the number of air tickets: \n", m);
scanf("%d ",& amps[i]。 Pu Shu);
Printf ("Please enter the fare: \n", m);
scanf("%d ",& amps[i]。 Piaojia);
Printf ("Please enter fare discount: \n", m);
scanf("%lf ",& amps[i]。 Park Zhekou);
m++;
Printf ("%d messages have been entered. Do you want to continue? Press any key to continue, press 0 to end ",m);
flush all();
scanf("%d ",& ampy);
If (y==0)
{
save();
Shu Chu ();
Break;
}
}
}
void shuchu()
{
char w[ 10];
read();
Printf ("flight number, flight number, departure station, terminal time, ticket number, fare discount \ n");
for(I = 0; I & ltm;; i++)
{
printf(print 1);
}
Printf ("Please press any key to end and return to the parent menu: \ n");
scanf("%s ",w);
}
Invalid save ()
{
FILE *fp,* FP 1;
if((fp=fopen("a.txt "," wb"))==NULL)
{
Printf ("Failed to create file! \ n \ n ");
getchar();
Return;
}
if((fp 1=fopen("b.txt "," wb"))==NULL)
{
Printf ("Failed to create file! \ n \ n ");
getchar();
Return;
}
for(I = 0; I & ltm;; i++)
if(fwrite(& amp; s[i],sizeof(struct air), 1,fp)==0)
Printf ("Cannot input data into file! \ n \ n ");
fprintf(fp 1,“%d”,m);
fclose(FP);
fclose(FP 1);
}
Invalid read ()
{
FILE *fp,* FP 1;
if((fp=fopen("a.txt "," Rb ")= = NULL)
{
Printf ("Error, please check whether the file exists, and press any key to return to the main menu");
getchar();
}
if((fp 1=fopen("b.txt "," rb"))==NULL)
{
Printf ("Failed to create file! \ n \ n ");
getchar();
Return;
}
fscanf(fp 1," %d ",& ampm);
fclose(FP 1);
for(I = 0; I & ltm;; i++)
{
Fred (& amps[i], sizeof(air), 1, FP);
}
fclose(FP);
}
Void inquiry ()
{
char name 1[20];
char name 2[20];
char c[ 10],no[20];
int n;
do
{
Printf ("Please select query information: \ n \ n");
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n \ n ");
Printf("* 1。 Inquire about airline information * \n\n "
"* 2. Inquiring about customer information * \n\n"
"* 0.return * \ n \ n ");
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n \ n ");
Printf ("Please choose from 0-2: \n\n"
"Press other keys and end with Enter to return to the main menu: \ n \ n");
scanf("%d ",& ampn);
If (n==0)
Break;
other
Switch (n)
{Case 1:
Printf ("Please enter the name of the originating station: \ n");
scanf("%s ",name 1);
Printf ("Please enter a terminal name: \ n");
scanf("%s ",name 2);
Break;
Case 2:
Printf ("Please enter the customer's ID number: \ n");
Scanf("%s ",no);
Break;
}
read();
for(I = 0; I & ltm;; i++)
{
if(strcmp(s[i].over,name 1)==0||strcmp(s[i].over,name2)==0)
Printf ("\ nSearch flight information successfully! \ n ");
Printf ("flight number, flight number, departure station, terminal time, ticket number, fare discount \ n");
printf(print 1);
Break;
}
other
if(strcmp(t[i])。 id,no)==0)
{
Printf ("\ nCustomer information found successfully! \ n ");
Printf ("ID number, flight number, flight number and ticket number");
printf(print 2);
Break;
}
}
Printf ("No information you need or search is complete: \n\n"
"Do you want to continue the search? Type y or n to end with Enter \ n ");
scanf("%s ",c);
}while(strcmp(c," y ")= = 0);
}
The beginning of the void mountain ()
{
char name 1[20];
char name 2[20];
char c[ 10];
int no,n;
do
{
Printf ("Please select Delete to end with carriage return: \ n \ n");
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n \ n ");
Printf("* 1。 Delete by flight number *\n\n "
"* 2. Delete by airline *\n\n"
"* 0.return * \ n \ n ");
printf(" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \ n \ n ");
Printf ("Please choose 0-2 to end with carriage return: \ n");
scanf("%d ",& ampn);
If (n==0)
Break;
Switch (n)
{
Case 1:
Printf ("Please enter flight number: \ n");
Scanf("%d ",&no);
read();
Break;
Case 2:
Printf ("Please enter the name of the originating station: \ n");
scanf("%s ",name 1);
Printf ("Please enter a terminal name: \ n");
scanf("%s ",name 2);
read();
Break;
}
for(I = 0; I & ltm;; i++)
{
If (s[i]. num==no||strcmp(s[i].start,name 1)= = 0 & amp; & ampstrcmp(s[i].over,name2)==0)
{
s[I]= s[m- 1];
m-;
}
}
Printf ("Search completed or no such information \ n \ n");
Printf ("Continue deleting \ n");
Printf ("Please type y or n to end with Enter \ n");
scanf("%s ",c);
save();
If (! strcmp(c," y "))
Printf ("Please press any key to return to the upper menu: \ n");
Break;
}while(n! = 1。 & ampn! = 2 & amp& ampn! =0);
}
Invalid booking ()
{ int n;
char a[ 10],b[ 10];
do
{
Printf ("Please enter customer ID number: \ n");
scanf("%d ",& ampt[i]。 id);
Printf ("Please enter flight number: \ n");
scanf("%s ",b);
Printf ("Please enter the plane number: \ n");
scanf("%d ",& amps[i]。 num);
flush all();
m++;
Printf ("Please enter the number of air tickets you want to book: \ n");
scanf("%d ",& ampn);
If(strcmp(s[i]. Hangban, b)! =0)
{
Printf ("Please enter a valid ticket number! \ n ");
Break;
}
other
If (s[i]. Pu Shu! = 0 & amp& amps[i]。 Gone with the wind book & gt=n)
{
s[i]。 Piaoshu =s[i]. Pu Shu-n;
save();
Printf ("Booked successfully, press any key to return to the main menu! \ n \ n ");
getchar();
Break;
}
Printf ("Do you want to continue? Please enter y or n to end with carriage return: \ n ");
scanf("%s ",a);
}while(! strcmp(a," y "));
}
Void Refund ()
{
int n;
char a[ 10],b[20];
do
{printf ("Please enter the customer ID number: \ n");
scanf("%s ",b);
Printf ("Please enter the number of air tickets you want to refund: \ n");
scanf("%d ",& ampn);
if(strcmp(b,t[i])。 id)==0)
{s[i]。 Piaoshu =s[i]. Pu Shu+n;
save();
Printf ("Refund successful! \ n \ n "); }
Else {printf ("Refund failed! \ n ");
Printf ("Do you want to continue? Please type y or n to end with Enter: \ n \ n ");
scanf("%s ",a);
}while(! strcmp(a," y "));
getchar();
}
- Previous article:Activity plan for Teachers’ Day in Central Primary School
- Next article:Safety slogans and civilized language
- Related articles
- How to draw a spring poster? How to draw a spring pictorial
- Integrity and integrity blackboard newspaper design content material
- Host speech at the 2020 Olympic Games
- How do people in China celebrate New Year's Day?
- Crime prevention slogans, warnings, prompts
- 60 words broadcast script for sports meeting cheers
- Discuss whether college education has nothing to do with future success.
- How can I lose weight quickly?
- After the national football losing streak, the fans began to have a wrong feeling about Lippi. Do you remember what Lippi said?
- 6 speeches by civil aviation professionals