停车管理程序

时间:2022-04-17 20:11:33 停车制度 我要投稿
  • 相关推荐

停车管理程序

#define NULL 0

#define OK 1

#define ERROR 0

typedef struct airline{

char air_num[8];

char plane_num[8];

char end_place[20];

int  total;

int  left;

struct airline *next;

}airline;

typedef struct customer{

char name[8];

char air_num[8];

int  seat_num;

struct customer *next;

}customer;

airline *start_air()

{

airline *a;

a=(airline*)malloc(sizeof(airline));

if(a==NULL)

a->next=NULL;

return a;

}

customer *start_cus()

{

customer *c;

c=(customer*)malloc(sizeof(customer));

if(c==NULL)

c->next=NULL;

return c;

}

airline *modefy_airline(airline *l,char *air_num)

{

airline *p;

p=l->next;

for(;p!=NULL;p=p->next)

{

if(strcmp(air_num,p->air_num)==0)

{

p->left++;

return l;

}

printf("NO the airline!");

return 0;

}

}

int insert_air(airline **p,char *air_num,char *plane_num,char *end_place,int total,int left)

{

airline *q;

q=(airline*)malloc(sizeof(airline));

strcpy(q->air_num,air_num);

strcpy(q->plane_num,plane_num);

strcpy(q->end_place,end_place);

q->total=total;

q->left=left;

q->next=NULL;

(*p)->next=q;

(*p)=(*p)->next;

return OK;

}

int  insert_cus(customer **p,char *name,char *air_num,int seat_num)

{

customer *q;

q=(customer*)malloc(sizeof(customer));

strcpy(q->name,name);

strcpy(q->air_num,air_num);

q->seat_num=seat_num;

q->next=NULL;

(*p)->next=q;

(*p)=(*p)->next;

return OK;

}

int yuding(airline *a,char *air_num,customer *c,char *name)

{

airline *p=a;

customer *q;

p=a->next;

if(c) q=c;

else {

for(q=c->next;q->next!=NULL;q=q->next){}   }

for(;p->next!=NULL;p=p->next)

{

if(p->left>0)

{

printf("Your seat number is %d",(p->total-p->left+1));

insert_cus(&q,name,air_num,p->total-p->left+1);

p->left--;

return OK;

}

else

{

printf("seat is full");

return 0;

}

}

}

int del_cus(customer *c,airline *l,char *name)

{

customer *p,*pr;

char air_num[8];

pr=c;

p=pr->next;

while(p!=NULL)

{

if(strcmp(p->name,name)==0)

{

strcpy(air_num,p->air_num);

l=modefy_airline(l,air_num);

pr->next=p->next;

p=pr->next;

printf("finish!");

return OK;

}

pr=pr->next;

p=pr->next;

}

printf("NO the customer!");

return ERROR;

}

int search_air(airline *head)

{

airline *p=head->next;

printf("air_num  plane_num  end_place  total  left\n");

for(;p!=NULL;p=p->next)

{

printf("%s    %-10s %-8s    %-8d%-8d\n",p->air_num,p->plane_num,p->end_place,p->total,p->left);

}

return OK;

}

int search_cus(customer *head)

{

struct customer *q=head->next;

printf("name    air_num    seat_num\n");

for(;q!=NULL;q=q->next)

{

printf("%-8s%-12s%-d\n",q->name,q->air_num,q->seat_num);

}

return OK;

}

int creat_air(airline **l)

{

airline *p=*l;

int i=0;

char *air_num[3]={"NO1af","NO2af","NO3af"};

char *plane_num[3]={"plane1","plane2","plane3"};

char *end_place[3]={"Beijing","Shanghai","Tianjin"};

int total[3]={100,100,100};

int left[3]={100,100,100};

for(i=0;i<3;i++)

insert_air(&p,air_num[i],plane_num[i],end_place[i],total[i],left[i]);

return OK;

}

void main()

{

int t=1;

customer *cus=NULL;

airline  *air=start_air();

char name[8],air_num[8],ch;

creat_air(&air);

while(t==1)

{

printf("\n");

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

printf("*     Welcome to air firm!      *\n");

printf("*         yuding--------1       *\n");

printf("*         tuipiao------2        *\n");

printf("*         chakan------3         *\n");

printf("*         exit--------4         *\n");

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

ch=getch();

switch(ch)

{case'1':

printf("Please input a airline number:");

scanf("%s",air_num);

printf("Please input a name:");

scanf("%s",name);

yuding(air,air_num,cus,name);break;

case'2':

printf("Please input the tuipiao' name:");

scanf("%s",name);

del_cus(cus,air,name); break;

case'3':

search_air(air);

printf("\n");

search_cus(cus); break;

case'4':

t=0;break;

}

} clrscr();

}

【停车管理程序】相关文章:

工程招标管理程序05-19

停车场停车管理制度12-13

停车场停车管理制度精选15篇12-16

停车场停车管理制度(15篇)12-15

停车场停车管理制度15篇12-14

停车岗位职责03-06

停车场教案03-27

《停车场》教案02-11

小区停车整改方案05-19

停车场停车管理制度合集15篇12-17