飞机订票系统模拟说明书.docx

上传人:b****5 文档编号:30172642 上传时间:2023-08-05 格式:DOCX 页数:23 大小:139.19KB
下载 相关 举报
飞机订票系统模拟说明书.docx_第1页
第1页 / 共23页
飞机订票系统模拟说明书.docx_第2页
第2页 / 共23页
飞机订票系统模拟说明书.docx_第3页
第3页 / 共23页
飞机订票系统模拟说明书.docx_第4页
第4页 / 共23页
飞机订票系统模拟说明书.docx_第5页
第5页 / 共23页
点击查看更多>>
下载资源
资源描述

飞机订票系统模拟说明书.docx

《飞机订票系统模拟说明书.docx》由会员分享,可在线阅读,更多相关《飞机订票系统模拟说明书.docx(23页珍藏版)》请在冰豆网上搜索。

飞机订票系统模拟说明书.docx

飞机订票系统模拟说明书

*******************

实践教学

*******************

 

兰州理工大学

计算机与通信学院

2010年春季学期

算法与数据结构课程设计

 

题目:

飞机订票系统摸拟

专业班级:

08级计算机

(2)班

姓名:

黄建宏

学号:

08240212

指导教师:

王旭阳

成绩:

目录

摘要1

前言2

基本算法的实现3

采用类c语言定义相关的数据类型3

各模块的伪码算法4

函数的调用关系图6

调试分析7

测试结果8

源程序(带注释)11

总结22

参考文献23

致谢24

附件Ⅰ部分源程序代码25

摘要

该设计要求对飞机航班信息进行排序和查找。

可按航班的班号、起点站、到达站、起飞时间以及到达时间等信息时行查询。

对于本设计,主要是通过线性表的逻辑结构、存储结构,线性表及队列上基本运算实现的。

可以让我们学会如何把学到的知识用于解决实际问题。

关键词:

航班信息;客户信息;链式存储结构;

 

前言

飞机在现今的社会中已是越来越重要了,人们在旅游、工作、学习等生活中对飞机几乎是不可缺少了。

而由乘坐飞机所引起的问题也深入到了计算机领域,飞机订票系统就是解决这种问题的一种途径。

如人们常常在订票前要对问很多信息(飞机的起落时间,机票的价格,乘坐的人数以及是否有票等等)。

这个系统主要是由线性表的链式存储结构以及队列的存储结构来存储航班信息与客户信息的。

它的主要功能:

1、是录入航班信息,其调用函数为—insert_airline;

2、查询航线(航班号,飞机号,日期,航班容量,余票数),其调用函数为:

search_air;

3、订票(根据客户提供的情况,办理订票手续),其调用函数为:

book_air;4、承办退票业务(根据客户提供的情况,办理退票手续),其调用函数为:

del_cus;

5、删除已有航班信息,其调用函数为:

del_airline.

设计这样的一个系统可以很快的查出人们所需要的信息,能省去很多的步骤,而且还非常的准确。

基本算法的实现

采用类c语言定义相关的数据类型

定义航班信息:

typedefstructairline

{

charair_num[8];

charplane_num[8];

charend_place[20];

chartime_plane[16];

inttotal;

intleft;

structairline*next;

}airline;

定义客户信息:

typedefstructcustomer

{

charname[8];

charair_num[8];

intseat_num;

structcustomer*next;

}customer;

 

各模块的伪码算法

1.添加元素:

StatuslistInsert_L(LinkList&L,intI,ElemTyple)

{p=L;j=0;

While(p&&j

{p=p->next;j++;}

If(!

p11j>i-1)

ReturnError;

s=(Linklist)malloc(sizeof(LNode));

s->data=e;s->next=p-next;

returnok;

}

2.删除元素:

StatusListDelete_(LinkList&L,inti,ElemType&e)

{p=L;j=0;

While(p->next&&j

{p=p->next;++j;

}

If(!

(p->next)||j>i-1)

ReturnError;

q=p->next;p-next=q->next;

e=q->data;free(q);

returnok;

}

3查找元素:

StatusGetElem_L(LilkListL,inti,ElemType&e)

{p=L_>next;j=1;

While(p&&j

{p=p->next;++j;

}

If(!

p||j>i)

Returnerror;

E=p->data;

Returnok;

}

 

函数的调用关系图

 

调试分析

调试中遇到的问题及对问题的解决方法

1、输出的运行界面不整齐,例如“*”在编写程序的时候输入不整齐,运行出来的界面就不好看。

2、在使用解释符号时应该注意“//”,不适合于TC的环境,要用“/**/”。

3、函数的调用不正确。

解决方法:

当在一个函数中要调用另一个函数时,必须在调用函数的函数块中对被调用函数进行类型的声明

 

测试结果

定票:

退票:

查询航线“

添加航线:

删除已有航班信息:

 

源程序(带注释)

#include

#include

#include

#defineOK1

#defineERROR0

typedefstructairline//飞机编号结构体//

{charair_num[8];

charplane_num[8];

charend_place[20];

inttotal;

intleft;

structairline*next;

}airline;

typedefstructcustomer//乘客编号结构体//

{charname[8];

charair_num[8];

intseat_num;

structcustomer*next;

}customer;

airline*start_air()//1号函数//

{

airline*a;

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

if(a!

=NULL)

a->next=NULL;

returna;

}

customer*start_cus()//2号函数//

{

customer*c;

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

if(c!

=NULL)

c->next=NULL;

returnc;

}

airline*modefy_airline(airline*l,char*air_num)//3号函数//

{

airline*p;

p=l->next;

for(;p!

=NULL;p=p->next)

{

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

{

p->left++;

returnl;

}

}

printf("没有该航班!

");

return0;

}

intinsert_air(airline**p,char*air_num,char*plane_num,char*end_place,inttotal,intleft)//4号函数//

{

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;

printf("添加航线成功!

");

returnOK;

}

airline*add_air(airline*p,char*air_num,char*plane_num,char*end_place,inttotal,intleft)

{

airline*q,*pt;

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;

pt=p;

while((p)!

=NULL)

{

p=p->next;

}

p->next=q;

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

printf("添加航线成功!

");

returnpt;

}

intinsert_cus(customer**p,char*name,char*air_num,intseat_num)//5号函数//

{

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;

returnOK;

printf("添加客户成功!

");

}

intbook(airline*a,char*air_num,customer*c,char*name)//6号函数//

{airline*p=a;

customer*q=c->next;

p=a->next;

for(;q->next!

=NULL;q=q->next)

{

for(;p->next!

=NULL;p=p->next)

{

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

{

if(p->left>0)

{printf("你的座位号是:

%d",(p->total-p->left+1));

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

p->left--;

returnOK;

}

elseif(p->left==0)

{

printf("座位已满!

");

return0;

break;

}

}

else

{printf("没有该航班!

");

}

}

}

return1;

}

intdel_cus(customer*c,airline*l,char*name)//7号函数//

{customer*p,*pr;

charair_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("完成!

");

returnOK;

}

pr=pr->next;

p=pr->next;

}

printf("没有该顾客!

");

returnERROR;

}

intdel_airline(airline*l,customer*m,char*air_n)//8号函数//

{airline*pt,*ptr;

customer*p,*pr;

ptr=l;

pr=m;

p=pr->next;

pt=ptr->next;

while(pt!

=NULL)

{

if(strcmp(pt->air_num,air_n)==0)

{

ptr->next=pt->next;

while(p!

=NULL)

{

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

{pr->next=p->next;

printf("乘坐该航班的顾客%s已删除!

",p->name);

free(p);

p=pr->next;

}

pr=pr->next;

p=pr->next;

}

free(pt);

pt=ptr->next;

printf("删除该航班成功!

");

returnOK;

}

ptr=ptr->next;

pt=ptr->next;

}

printf("没有该航班!

");

returnERROR;

}

intsearch_air(airline*head)//9号函数//

{airline*p=head->next;

printf("air_numplane_numend_placetotalleft\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);

}

returnOK;

}

intsearch_cus(customer*head)

{structcustomer*q=head->next;

printf("nameair_numseat_num\n");

for(;q!

=NULL;q=q->next)

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

}

returnOK;

}

intcreat_air(airline**l)

{airline*p=*l;

inti=0;

char*air_num[3]={"007af","008af","009af"};

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

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

inttotal[3]={100,100,100};

intleft[3]={52,54,0};

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

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

returnOK;

}

intcreat_cus(customer**l)

{customer*p=*l;

inti=0;

char*name[3]={"zhsan","lisi","wangwu"};

char*air_num[3]={"007af","008af","010ll"};

intseat_num[3]={2,5,7};

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

insert_cus(&p,name[i],air_num[i],seat_num[i]);

returnOK;

}

voidmain()

{

intt=1;

customer*cus=start_cus();

airline*air=start_air();

charname[8],air_num[8],plane_num[8],end_place[20],ch;

intleft1,total1;

creat_air(&air);

creat_cus(&cus);

printf("\n");

//clrscr();

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

printf("*Welcometoairfirm!

*\n");

printf("*定票-----------------1*\n");

printf("*退定-----------------2*\n");

printf("*查询-----------------3*\n");

printf("*新建航班------------4*\n");

printf("*删除已有航班---------5*\n");

printf("*退出-----------------6*\n");

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

printf("\n请选择1-6:

");

do

{ch=getchar();

switch(ch)

{case'1':

printf("Pleaseinputaairlinenumber:

");

scanf("%s",&air_num);

printf("Pleaseinputaname:

");

scanf("%s",&name);

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

case'2':

printf("Pleaseinputthecancelname:

");

scanf("%s",&name);

del_cus(cus,air,name);break;

case'3':

search_air(air);

printf("\n");

search_cus(cus);break;

case'4':

printf("请输入想插入的航班号的air_num:

");

scanf("%s",&air_num);

printf("请输入飞机编号的plane_num:

");

scanf("%s",&plane_num);

printf("请输入飞机目的地end_place:

");

scanf("%s",&end_place);

printf("请输入飞机总座位数的total:

");

scanf("%d",&total1);

printf("请输入飞机剩余座位数的left:

");

scanf("%d",&left1);

add_air(air,air_num,plane_num,end_place,total1,left1);

break;

case'5':

printf("请输入想的删除航班号的air_num:

");

scanf("%s",&air_num);

del_airline(air,cus,air_num);break;

default:

exit(0);

}

if(ch=='6')

{break;

}

}while(t=1);

}

总结

在这三周的数据结构课程设计学习中,我通过我的课题:

飞机订票系统摸拟,我加深了对线性表以及队列的逻辑存储结构和物理存储结构的认识,对课本中所学的各种数据结构进一步理解和掌握,学会了如何把学到的知识用于解决实际问题,锻炼了自己动手的能力。

我在程序运行中发现了很多的错误,这说明我在数据结构课程的学习中还存在很多的问题,这些问题我以前从未发现过,这次的课程设计不仅解决了这些问题,而且让我认识到了动手能力的重要性。

如果不是自己做了这次设计,我也不可能以现这么多,我在老师和同学的帮助下竟意外的完成了课设,我真是很高兴,在感谢老师和同学的同时,我也对自己有了很大的信心。

三周的课程设计很短暂,但其间的内容是很充实的,在其中我学习到了很多平时书本中无法学到的东西,积累了经验,锻炼了自己分析问题,解决问题的能力,并学会了如何将所学的各课知识融会,组织,来配合学习,三周中我收益很大,学到很多。

参考文献

1.张永,《数据结构(C语言版)》,清华大学出版社。

3.《DATASTRUCTUREWITHC++》,WilliamFord,WilliamTcpp,清华大学出版社(影印版)。

4.王连相,赵付清,《C/C++语言程序设计》,清华大学出版社。

5严蔚敏,吴伟民.《数据结构(C语言版)》.清华大学出版社.

6严蔚敏,吴伟民.《数据结构题集(C语言版)》.清华大学出版社.

7《DATASTRUCTUREWITHC++》.WilliamFord,WilliamTopp.清华大学出版社(影印版).

8谭浩强.《c语言程序设计》.清华大学出版社.

9.数据结构与算法分析(Java版),APracticalIntroductiontoDataStructuresandAlgorithmAnalysisJavaEditionCliffordA.Shaffer,张铭,刘晓丹译 电子工业出版社2001年1月

 

致谢

首先感谢我的指导老师王旭阳老师,她在我的课程设计过程中提出了指导性的方案和架构,并指引我阅读相关的资料和书籍,使我在不熟悉的领域中仍能迅速掌握新的技术。

感谢我的数据结构老师张永老师在以往的基础课学习中为我打下良好的基础,这是我这次课程设计能够顺利完成的前提。

我的同学在设计完成后对程序的测试,没有他们,也许就难以发现一些潜在的错误,在此一并表示感谢。

 

附件Ⅰ部分源程序代码

#include

typedefintKeyType;

typedefstruct

{

KeyTypekey;

}ElemType;

intSeqSearch(ElemTypes[],KeyTypekey,intn);

main()

{

intkey;

KeyTypeKey;

ElemTypes[6]={15,25,89,40,55,10};

intn=6,i;

printf("请输入要查找的关键字:

");

scanf("%d",&key);

i=SeqSearch(s,key,n);

if(i!

=-1)

printf("\n查找成功!

%d是第%d个元素",key,i);

else

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 经管营销 > 财务管理

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1