百分求以下代码—仓库管理系统或航空售票系统
航空售票系统代码
#define N 5
#include "stdio。h"
#include "stdlib。h"
#include "malloc。h"
#include "string。 h"
typedef struct flightdetail
{
char customer[10];
int num;
struct flightdetail *next;
}flightdetail;
typedef struct flightmange
{
char name[20];
int booked;
int ticket;
int flightnum;
flightdetail ...全部
航空售票系统代码
#define N 5
#include "stdio。h"
#include "stdlib。h"
#include "malloc。h"
#include "string。
h"
typedef struct flightdetail
{
char customer[10];
int num;
struct flightdetail *next;
}flightdetail;
typedef struct flightmange
{
char name[20];
int booked;
int ticket;
int flightnum;
flightdetail *next;
}flightmange;
void init(flightmange* fl,char fn[][20],int fnum[],int tic[] )
{
int i;
flightdetail *fd;
for(i=0;inext==NULL;
}
}
void printall(flightmange* fl,int *length)
{
int i;
printf("\tAll Flght Information\n\n");
printf("Flightname Flightnum All Sold Rest\n\n");
for(i=0;i=1)
{
q=fl[t]。
next->next;
p=(flightdetail *)malloc(sizeof(flightdetail));
strcpy(p->customer,na);
p->num=nn;
p->next=q;
fl[t]。
next->next=p;
fl[t]。booked+=nn;
printf("\nDear %s,You have successfully booked %s Thanks for Using\n\tPress Any Key to Return",p->customer,fl[t]。
name);
getch();
return;
}
else
{
printf("\nSorry,We Don't Have Enougth Ticket(s) For You\n\tPress to Reenter Or Press to Exit");
do
{
key=getch();
}while(key!='Y'&&key!='y'&&key!='n'&&key!='N');
}
if(key=='Y'||key=='y')
{
system("cls");
printf("Welcome to the Booking System\n\n");
continue;
}
else {
printf("\nBooking Failed ,Thanks for Using");
return;
}
}
}
flightdetail* findname(flightdetail *m,char na[])
{
flightdetail *p=m;
m=m->next;
while(m)
{
if(strcmp(m->customer,na)==0) return p;
p=m;
m=m->next;
}
return NULL;
}
void returntic(flightmange *fl,int *length)
{
int i=0,n=0,t=999,nn=0;
char na[10],key;
flightdetail *p,*q;
printf("Welcome to the Return Ticket System\n\n");
while(1)
{
printf("\nStep1。
Please Input the Num of the Flight You Want to return:");
scanf("%d",&n);
t=findflight(fl,n,length);
if(t==999)
{
printf("\nthe Num of the Flight You Entered Not Find,\n\tPress to Reenter Or Press to Exit");
do
{
key=getch();
}while(key!='Y'&&key!='y'&&key!='n'&&key!='N');
if(key=='n'||key=='N')
{
printf("\n\tOperation Failed ,Thanks for Using");
getch();
return;
}
else{
system("cls");
printf("Welcome to the Booking System\n\n");
continue;
}
}
printf("\nCorrect Flight Num!\n\n");
printf("Step2。
Tell Us Your Name,We'll Check Our Database:");
scanf("%s",na);
p=findname(fl[t]。next,na);
if(p==NULL)
{
printf("\nYour Name Not Find,Make Sure You Have Entered Correctly\n\tPress to Reenter Or Press to Exit");
do
{
key=getch();
}while(key!='Y'&&key!='y'&&key!='n'&&key!='N');
if(key=='n'||key=='N')
{
printf("\n\tOperation Failed ,Thanks for Using");
getch();
return;
}
else{
system("cls");
printf("Welcome to the Booking System\n\n");
continue;
}
}
printf("\nFlightName Yourname TicketQuantity ");
printf("\n%-20s%-10s %-5d",fl[t]。
name,p->next->customer,p->next->num);
printf("\nStep3。Now Tell Us How Many Ticket You Want to Retrun:");
scanf("%d",&nn);
q=p->next;
if(nn>q->num||nn to Reenter Or Press to Exit");
do
{
key=getch();
}while(key!='Y'&&key!='y'&&key!='n'&&key!='N');
if(key=='n'||key=='N')
{
printf("\n\tOperation Failed ,Thanks for Using");
getch();
return;
}
else{
system("cls");
printf("Welcome to the Booking System\n\n");
continue;
}
}
q->num-=nn;
printf("\nDear %s,You have successfully returned %d %s Ticket(s) Thanks for Using\n\tPress Any Key to Return",q->customer,nn,fl[t]。
name);
if(q->num==0)
{
p->next=q->next;
free(q);
}
fl[t]。booked-=nn;
getch();
break;
}
}
void search(flightmange *fl,int *length)
{ int ff=0,i;
char na[10];
flightdetail *p;
printf("Enter Your Name:");
scanf("%s",na);
printf("\n\nFlightname Flightnum Name Ticket Quantity \n\n");
for(i=0;inext;
while(p)
{
if(strcmp(p->customer,na)==0)
{
printf("%-20s",(fl[i])。
name);
printf(" %-8d",(fl[i])。flightnum);
printf(" %-10s",p->customer);
printf(" %-d\n",p->num);
ff++;
}
p=p->next;
}
}
if(!ff) printf("\n\tNo Match Find");
getch();
}
void create(flightmange *fl,int *length)
{ char na[20],password[]="123456",pa[7],key;
int m,n,i;
flightdetail *p;
printf("Enter Password:");
while(1)
{
for(i=0;i to Retry Or Press to Abort");
do
{
key=getch();
}while(key!='Y'&&key!='y'&&key!='n'&&key!='N');
if(key=='n'||key=='N')
{
printf("\n\tOperation Failed ,Thanks for Using");
getch();
return;
}
else{
system("cls");
printf("Enter Password:\n\n");
continue;
}
}
}
system("cls");
printf("Enter the Flight Name:");
scanf("%s",na);
printf("\nEnter the Flight Num:");
scanf("%d",&n);
printf("\nEnter the Tickets Quantity:");
scanf("%d",&m);
strcpy(fl[*length]。
name,na);
fl[*length]。flightnum=n;
fl[*length]。ticket=m;
fl[*length]。booked=0;
p=(flightdetail *)malloc(sizeof(flightdetail));
p->next=NULL;
fl[*length]。
next=p;
printf("\n\n\n");
printselect(fl,*length,n);
(*length)++;
getch();
}
void main()
{ char fn[N][20]={"NingboLondon","NingboShanghai","NingboBeijing","NingboTokyo","NingboNew York"};
int fnum[N]={1001,1002,1003,1004,1005},tic[N]={11,42,32,34,12};
char key;
flightmange *fl;
int size=50,length=N;
fl=(flightmange *)malloc(size*sizeof(flightmange));
init(fl,fn,fnum,tic) ;
system("cls");
printf("\t\t\t* * * * * * * * * *\n");
printf("\t\t\tTicket Mange System\n\n\t\t\t\ Programed by Yang Rida\n");
printf("\t\t\t* * * * * * * * * *\n");
printf("\nInfo:This Programe was Compiled With Visual C++,\n And Has Been Tested On TurboC2。
0");
getch();
printf("\nInitialize Success!\n\Now Press Any Key to Continue");
getch();
system("cls");
welcome();
while((key=getch())!='6')
{
switch(key)
{ case '1' :system("cls");create(fl,&length);system("cls");welcome();break;
case '2' :system("cls");booktic(fl,&length);system("cls");welcome();break;
case '3' :system("cls");returntic(fl,&length);system("cls");welcome();break;
case '4' :system("cls");printall(fl,&length);system("cls");welcome();break;
case '5' :system("cls");search(fl,&length);system("cls");welcome();break;
default :;
}
}
}
。
收起