2.3 测试用例设计 2.3.1 航线3条:1001 hp001 shanghai 2 50 paper51.com 1002 hp002 beijing 5 50 copyright paper51.com 1003 hp003 guangzhou7 50 内容来自www.paper51.com 2.3.2 查询航线:shanghai 内容来自论文无忧网 www.paper51.com
2.3.3 承办检票业务:航班号1001 数额30 姓名chengangjie 舱位等级2 内容来自www.paper51.com 2.3.4 承办检票业务:航班号1001 数额23 姓名zhenxi 舱位等级3 paper51.com 2.3.5 承办退票业务:姓名chengangjie航班号1001 飞行周日2 内容来自www.paper51.com 2.3.6 查询航线:终点站名:shanghai 内容来自www.paper51.com
3 调试分析 内容来自www.paper51.com
3.1 本次的设计比较困难,需要实现较多的功能,所以在调试过程中不太顺利,主要是指针的修改。经过反复调试以后才得以解决。 内容来自www.paper51.com 3.2 本程序航线采用数组的存储结构,每条航线包含8个域,其中乘员名单域为指向乘员名单链表的头指针,等候替补的客户名单域为分别指向对头和对尾的指针。 copyright paper51.com 3.3 检票函数是在退票业务模块中使用 内容来自论文无忧网 www.paper51.com 4 经验和体会 内容来自www.paper51.com 通过这次的程序设计,进一步理解了链表和队列结构的实现和应用。尤其需要注意的是:对于指针的修改要仔细,否则会发生意想不到的结果。 内容来自www.paper51.com
5 源程序清单和运行结果 内容来自论文无忧网 www.paper51.com 5.1程序清单 http://www.paper51.com #include<iostream.h> copyright paper51.com #include<iomanip.h> http://www.paper51.com #include<string.h> copyright paper51.com
#include<stdio.h> paper51.com #include<conio.h> http://www.paper51.com #define FLIGHT_NUM 100//航线最大数量 paper51.com
typedef struct Al_Custom //已检票客户 内容来自www.paper51.com { paper51.com charname[15];//姓名 paper51.com intcount;//检票量 内容来自论文无忧网 www.paper51.com
intlevel;//舱位等级 paper51.com Al_Custom*next;//下一节点指针 copyright paper51.com }Al_Custom,*Al_CustomLink; copyright paper51.com typedef struct Wait_Custom//等候替补的客户 paper51.com { http://www.paper51.com charname[15];//姓名 http://www.paper51.com intcount;//所需票量 paper51.com Wait_Custom*next;//下一节点指针 内容来自www.paper51.com }Wait_Custom; http://www.paper51.com typedef struct Wait_Queue//等待队列 http://www.paper51.com { 内容来自www.paper51.com Wait_Custom*front;//队列头指针 paper51.com Wait_Custom*rear;//尾指针 内容来自论文无忧网 www.paper51.com }Wait_Queue; 内容来自论文无忧网 www.paper51.com typedef struct Flight//航线 paper51.com { 内容来自论文无忧网 www.paper51.com charterminus[15];//终点站名 paper51.com
charflight_no[10];//航班号 内容来自www.paper51.com charplane_no[10];//飞机号 http://www.paper51.com intweek;//飞行周日 http://www.paper51.com intcount;//乘客定额 http://www.paper51.com intrest;//余票量 paper51.com Al_CustomLinkAl_link;//指向成员名单链表的头指针 http://www.paper51.com Wait_Queuewait_queue;//等待替补队列 paper51.com
}Flight; copyright paper51.com
void Custom_init(Al_CustomLink &L) 内容来自www.paper51.com { http://www.paper51.com L=newAl_Custom; paper51.com L->next=0; http://www.paper51.com } 内容来自论文无忧网 www.paper51.com void Custom_insert(Al_CustomLink&L,Al_Custom& custom) 内容来自论文无忧网 www.paper51.com { http://www.paper51.com
Al_Custom*p=L,*newnode=new Al_Custom; copyright paper51.com
memcpy((void*)newnode,&custom,sizeof(Al_Custom)); copyright paper51.com newnode->next=p->next; 内容来自www.paper51.com p->next=newnode; 内容来自www.paper51.com } http://www.paper51.com void copyCustomLink(Al_CustomLink&dest,Al_CustomLink &source)//复制已检票客户链表 内容来自论文无忧网 www.paper51.com { 内容来自论文无忧网 www.paper51.com Al_CustomLinkp=source; paper51.com Al_CustomLinkq; paper51.com
Al_Custom*pnew; 内容来自论文无忧网 www.paper51.com
Custom_init(dest); http://www.paper51.com q=dest; copyright paper51.com while(p->next) copyright paper51.com { http://www.paper51.com
pnew=newAl_Custom; 内容来自论文无忧网 www.paper51.com memcpy(pnew,p->next,sizeof(Al_Custom)); http://www.paper51.com
pnew->next=0; http://www.paper51.com q->next=pnew; 内容来自论文无忧网 www.paper51.com q=pnew; 内容来自论文无忧网 www.paper51.com
p=p->next; http://www.paper51.com } 内容来自论文无忧网 www.paper51.com
copyright paper51.com } 内容来自论文无忧网 www.paper51.com void Waiter_init(Wait_Queue &Q) copyright paper51.com { copyright paper51.com Q.front=Q.rear=newWait_Custom; copyright paper51.com Q.front->next=0; paper51.com } http://www.paper51.com
void Waiter_En(Wait_Queue&Q,Wait_Custom& custom) 内容来自论文无忧网 www.paper51.com { http://www.paper51.com Wait_Custom*newnode=new Wait_Custom; 内容来自www.paper51.com memcpy(newnode,&custom,sizeof(Wait_Custom)); paper51.com newnode->next=0; http://www.paper51.com Q.rear->next=newnode; paper51.com Q.rear=newnode; http://www.paper51.com } 内容来自论文无忧网 www.paper51.com bool Waiter_De(Wait_Queue&Q,Wait_Custom& custom) paper51.com { paper51.com if(Q.rear==Q.front) 内容来自论文无忧网 www.paper51.com returnfalse; 内容来自www.paper51.com memcpy(&custom,Q.front,sizeof(Wait_Custom)); paper51.com Wait_Custom*p=Q.front->next; copyright paper51.com Q.front->next=p->next; copyright paper51.com if(Q.rear!=Q.front) paper51.com Q.rear=Q.front; paper51.com deletep; 内容来自论文无忧网 www.paper51.com custom.next=0; http://www.paper51.com returntrue; 内容来自论文无忧网 www.paper51.com
} paper51.com 内容来自论文无忧网 www.paper51.com |