typedef struct Al_Custom //已订票客户 { char name[15];//姓名 int count;//订票量 int level;//舱位等级 Al_Custom *next;//下一节点指针 }Al_Custom,*Al_CustomLink;
typedef struct Wait_Custom//等候替补的客户 { char name[15];//姓名 int count;//所需票量 Wait_Custom *next;//下一节点指针 }Wait_Custom;
typedef struct Wait_Queue//等待队列 { Wait_Custom *front;//队列头指针 Wait_Custom *rear;//尾指针 }Wait_Queue;
typedef struct Flight//航线 { char terminus[15];//终点站名 char flight_no[10];//航班号 char plane_no[10];//飞机号 int week;//飞行周日 int count;//乘客定额 int rest;//余票量 Al_CustomLink Al_link;//指向成员名单链表的头指针 Wait_Queue wait_queue;//等待替补队列 }Flight;
void Custom_init(Al_CustomLink &L) { L=new Al_Custom; L->next=0; }
void Custom_insert(Al_CustomLink &L,Al_Custom& custom) { Al_Custom *p=L,*newnode=new Al_Custom; memcpy((void*)newnode,&custom,sizeof(Al_Custom)); newnode->next=p->next; p->next=newnode; }
void copyCustomLink(Al_CustomLink &dest,Al_CustomLink &source)//复制已订票客户链表 { Al_CustomLink p=source; Al_CustomLink q; Al_Custom *pnew; Custom_init(dest); q=dest; while(p->next) { pnew=new Al_Custom; memcpy(pnew,p->next,sizeof(Al_Custom)); pnew->next=0; q->next=pnew; q=pnew; p=p->next; } }
void Waiter_init(Wait_Queue &Q) { Q.front=Q.rear=new Wait_Custom; Q.front->next=0; }
void Waiter_En(Wait_Queue &Q,Wait_Custom& custom) { Wait_Custom *newnode=new Wait_Custom; memcpy(newnode,&custom,sizeof(Wait_Custom)); newnode->next=0; Q.rear->next=newnode; Q.rear=newnode; } bool Waiter_De(Wait_Queue &Q,Wait_Custom& custom) { if(Q.rear==Q.front) return false; memcpy(&custom,Q.front,sizeof(Wait_Custom)); Wait_Custom *p=Q.front->next; Q.front->next=p->next; if(Q.rear!=Q.front) Q.rear=Q.front; delete p; custom.next=0; return true; }
void copyWait_Queue(Wait_Queue &dest,Wait_Queue& source)//复制等待队列 { Wait_Custom *p=source.front; Waiter_init(dest); while(p->next) { Waiter_En(dest,*p); p=p->next; } }
int flight_no;//航线数量 Flight flight[FLIGHT_NUM];//航线数组
void initFlight(Flight &f)//初始化一条航线 {  
首页 上一页 1 2 3 4 5 下一页 尾页 2/5/5