数据结构航空客运订票系统.docx

上传人:b****8 文档编号:12535413 上传时间:2023-06-06 格式:DOCX 页数:28 大小:107.03KB
下载 相关 举报
数据结构航空客运订票系统.docx_第1页
第1页 / 共28页
数据结构航空客运订票系统.docx_第2页
第2页 / 共28页
数据结构航空客运订票系统.docx_第3页
第3页 / 共28页
数据结构航空客运订票系统.docx_第4页
第4页 / 共28页
数据结构航空客运订票系统.docx_第5页
第5页 / 共28页
数据结构航空客运订票系统.docx_第6页
第6页 / 共28页
数据结构航空客运订票系统.docx_第7页
第7页 / 共28页
数据结构航空客运订票系统.docx_第8页
第8页 / 共28页
数据结构航空客运订票系统.docx_第9页
第9页 / 共28页
数据结构航空客运订票系统.docx_第10页
第10页 / 共28页
数据结构航空客运订票系统.docx_第11页
第11页 / 共28页
数据结构航空客运订票系统.docx_第12页
第12页 / 共28页
数据结构航空客运订票系统.docx_第13页
第13页 / 共28页
数据结构航空客运订票系统.docx_第14页
第14页 / 共28页
数据结构航空客运订票系统.docx_第15页
第15页 / 共28页
数据结构航空客运订票系统.docx_第16页
第16页 / 共28页
数据结构航空客运订票系统.docx_第17页
第17页 / 共28页
数据结构航空客运订票系统.docx_第18页
第18页 / 共28页
数据结构航空客运订票系统.docx_第19页
第19页 / 共28页
数据结构航空客运订票系统.docx_第20页
第20页 / 共28页
亲,该文档总共28页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

数据结构航空客运订票系统.docx

《数据结构航空客运订票系统.docx》由会员分享,可在线阅读,更多相关《数据结构航空客运订票系统.docx(28页珍藏版)》请在冰点文库上搜索。

数据结构航空客运订票系统.docx

数据结构航空客运订票系统

航空客运订票系统

程序要求:

1、问题描述

航空客运订票得业务活动包括:

查询航线、客票预订与办理退票等。

设计一个航空客运订票系统,以使上述业务可以借助计算机完成。

2、要求

1)每条航线所涉及得信息有:

终点站名、航班号、飞机号、飞行周日(星期几)、乘员定额、余票量、已订票得客户名单(包括名字、订票量、舱位等级1、2、3)以及等候替补得客户名单;

2)系统实现得功能如下:

通过此系统可以实现如下功能:

录入:

可以录入航班情况(数据可以存储在一个数据文件中,数据结构、具体数据自定)

查询:

可以查询某个航线得情况(如,输入航班号,查询起降时间,起飞抵达城市,航班票价,票价折扣,确定航班就是否满仓);可以输入起飞抵达城市,查询飞机航班情况;

订票:

(订票情况可以存在一个数据文件中,结构自己设定)可以订票,如果该航班已经无票,可以提供相关可选择航班;

退票:

可退票,退票后修改相关数据文件;客户资料有姓名,证件号,订票数量及航班情况,订单要有编号。

修改航班信息:

当航班信息改变可以修改航班数据文件

存储结构:

航线得所有信息存储在一个结构体中,增加,查询,订票,退票等操作按队列得操作来实现。

程序流程图:

详细代码:

#include〈iostream、h>

#include

#include<string、h>

#include

#define m4   //3架飞机

#definen5 //每架飞机5张票

structnode

{ charname[21];

 charid[21];

intseat,plane,date;

 node*next,*pre;

};

struct wait

 charname[21];

 char id[21];

    char phone[8];

  int seat,plane,date,count;

wait*next,*pre;

};

structpiao

{

  intseat[n+1];

};

voidmakenull(); 

voidmakenull_piao();

voidmakenull_information();

voidlist_menu();

voidlist_piao();

voidmakenull_wait();

void list_information();

void plane_information(node *head);

voidbook();

voidadd_information(node*head,int x,inty);

voidadd_wait(intx,inty);

voidsearch_delete(intx);

void write_to_file();

voidshow_wait();

boolp(node *x,node*y);

node*head1,*head2,*head3,*q;

wait*wait_head,*wait_end;

char c;

piao a[m];

voidmain()

makenull();

do

 { list_menu();

 cout〈

  ”;

  cin〉〉c;

   if(c!

=’6’)

   switch(c)

  {

 case'0':

show_wait();break;

   case'1’:

{list_piao();book();}break;

 case’2':

search_delete(1);break;

   case'3' :

list_piao();break;

     case'4’:

list_information();break;

 case’5’:

search_delete(0);break;

    default:

break;

  }

}while(c!

='6’);

  cout<〈"ExitSystem";

voidmakenull()

 makenull_piao();

 makenull_information();

makenull_wait();

voidlist_menu()

{  cout〈

  cout〈<endl〈〈" 菜单";

cout<〈endl<<"   ************************";

cout<〈endl<〈"  * 0 、查瞧排队情况  *";

 cout<〈endl<〈” *1、 订票  *";

  cout〈〈endl〈<"  *   2、退票   *";

 cout<〈endl<<”  *3、查瞧剩余票 *”;

 cout<<endl<<” *4 、 查瞧飞机信息*”;

 cout<<endl〈〈"   *5 、查瞧乘客信息*";

 cout<〈endl〈<" *6 、退出   *";

cout〈〈endl〈<" ************************";

cout〈<endl<<”";

}

voidmakenull_piao()

FILE*fp;

inti;

  if((fp=fopen(”piao、dat","r"))==NULL)

 {

 fp=fopen("piao、dat”,”w");

  for(i=1;i<=m-1;i++)

   fwrite(&a[i],sizeof(piao),1,fp);

   fclose(fp);

  fp=fopen("piao、dat”,"r”);

 }

  for(i=1;i〈=m—1;i++)

 fread(&a[i],sizeof(piao),1,fp);

fclose(fp);

}

voidmakenull_information()

{

  node *r;

 FILE *fp;

inti,j,sum;

sum=a[1]、seat[0]+a[2]、seat[0]+a[3]、seat[0];

fp=fopen("information、dat”,"r”);

   head1=newnode;

  head2=newnode;

head3=newnode;

 head1—〉pre=NULL;

head1—>next=NULL;

head2->pre=NULL;

  head2—〉next=NULL;

  head3—>pre=NULL;

 head3->next=NULL;

 q=head1;

 for(i=1;i<=sum;i++)

j=0;

  r=new node;

  fread(r,sizeof(node),1,fp);

 q—>next=r;

   r—〉pre=q;

r->next=NULL;

q=q->next;

 fclose(fp);

   if(i==a[1]、seat[0]+1){

head2->next=q;

   q—〉pre—>next=NULL;

q—>pre=head2;

 }

if(i==a[1]、seat[0]+a[2]、seat[0]+1){

    head3—>next=q;

     q—>pre-〉next=NULL;

q—>pre=head3;

  }

 }

}

voidmakenull_wait()

{

wait*tempw;

 FILE *fp;

  tempw=newwait;

inti;

  if((fp=fopen(”wait、txt",”r”)) ==NULL)

   fp=fopen("wait、txt","w");

   fclose(fp);

  }

wait_end=new wait;

wait_head=newwait;

   wait_end->next=NULL;

 wait_end—〉pre=NULL;

 wait_head=wait_end;

  wait_head-〉count=0;

 fp=fopen("wait、txt","r”);

fread(wait_head,sizeof(wait),1,fp);

      for(i=1;i〈=wait_head->count;i++)

    {

    fread(tempw,sizeof(wait),1,fp);

    wait_end-〉next=tempw;

  tempw->pre=wait_end;

     tempw->next=NULL;

      wait_end=tempw;

 }

}

voidlist_piao()

 inti,j;

 for(i=1;i<=m-1;i++)

   {

   if(a[i]、seat[0]!

=n)

 {

       cout<<endl<<"第 ”<〈i<〈"架飞机剩余得票 :

"<〈endl;

  for(j=1;j〈=n;j++) 

       if(a[i]、seat[j]==0)cout<〈”"<〈j;

     cout〈

  }

   elsecout<<endl<〈"The "<<i<〈”plane isfull!

"〈〈endl<

 }

void list_information()

int x;

 do {cout<<endl<<”显示哪架飞机得信息 ?

”; cin〉>x;cout<〈endl;}while(x〈1||x〉=m);

 cout<〈endl<〈"第"<〈x〈<" 架飞机得信息如下"〈<endl;

  if(x==1)plane_information(head1);

 if(x==2) plane_information(head2);

 if(x==3)plane_information(head3);

void plane_information(node*head)

node*q;

   char ch;

intx=0;

  if(head!

=NULL&& head->next!

=NULL) 

     q=head-〉next;

else{

     q=NULL; 

  cout<<”飞机空,无预订票!

”〈

 }

  while(q!

=NULL)

 {

  cout〈<endl〈〈”*******************”〈<endl;

  q->date=q—〉plane;

     cout〈<”日期 :

"<

cout<<”座位号:

"〈<q-〉seat<<endl;

 cout<〈”姓名:

"<〈q->name;

  cout<<endl〈〈”ID号:

 "<<q-〉id;

   q=q—>next;x++;

   if (x %3==0) ch=getch();

}

cout<〈endl;

}

voidbook()

{

  inti,j,p;

 cout〈〈endl<<"请选择地点:

(1、2、3) ";

do{

  cin>〉i;

    if (i〈1 || i>=m){

   cout〈<endl<〈"****超出范围!

****"<

";

 }

  else

 {cout<<endl〈〈"您要订得就是到”<〈i<〈”地得飞机"〈〈endl;

   cout<

”<<endl;

  for(p=1;p<=n;p++)

    if (a[i]、seat[p]==0)cout<<”"<<p;

   cout<

 break;}

 }while

(1);

   cout〈〈endl〈<”请选择座位号 :

";

 do {

 cin〉>j;

   if(j〈1 ||j>n){

      cout<〈endl<<"****超出范围!

****"<〈endl<<"请重新输入:

";

}

   else 

   {

    q—〉date=i;

   cout<

"<date〈〈endl;

   break;

 }

}while

(1);

if(a[i]、seat[j]==0) {

    a[i]、seat[j]=1;

 cout<〈endl;

 a[i]、seat[0]++;

 if(i==1) add_information(head1,1,j);

 if(i==2)add_information(head2,2,j);

  if(i==3)add_information(head3,3,j);

 }

  else

 { cout〈<endl<〈"****对不起,该座位已被预订,您被安排到订票等候队列****”<

 add_wait(i,j);

}

}

voidadd_wait(int x,inty)

{

 wait*tempw;

tempw=new wait;

 tempw->next=NULL;

cout〈<"请输入个人信息"<<endl;

 cout〈<endl<<"*************"<<endl;

 cout<〈"姓名:

”;cin〉〉tempw-〉name;

cout<〈"ID号:

 ";cin>>tempw—>id;

cout<〈"电话 :

";cin>>tempw->phone;

tempw->seat=y;

 tempw—>plane=x;

 wait_end—>next=tempw;

tempw->pre=wait_end;

 wait_end=wait_end->next;

cout〈

  wait_head—〉count++;

  write_to_file();

}

voidshow_wait()

  wait*tempw;

 tempw=wait_head->next;

if(tempw==NULL)cout〈<endl<<"排队中没有人!

"〈<endl;

  while(tempw!

=NULL)

 cout<

tempw=tempw—>next;

 }

}

void add_information(node *head,intx,inty)

node*temp;

  temp=newnode;

temp—>pre=NULL;

temp-〉next=NULL;

cout〈〈”请输入个人信息"〈<endl;

cout〈〈endl<<”*************”<<endl;

 cout〈<"姓名:

 ";cin>>temp->name;

  cout<<"ID号:

";cin>〉temp->id;

 temp—〉seat=y;

temp->plane=x;

temp->next=head->next;

  temp->pre=head;

  if (head->next!

=NULL) head—>next->pre=temp;

 head->next=temp;

 write_to_file();

cout<

voidsearch_delete(intx)

{

node *p,*q,*r;

  wait*tempw,*tempw2,*tempw3;

intstep=1,t1,t2,i;

 charch;

 p=newnode;

 tempw=newwait;

 tempw2=newwait;

 tempw3=new wait;

 q=head1;

 cout<<endl〈<”请输入个人信息”〈

  cout<〈"*************”<〈endl;

 cout<〈endl<〈"姓名:

”;cin〉〉p->name;

 do{

    q=q->next;

  if((q!

=NULL)&&

   (p(q,p)) )

 {

  cout<〈endl;

 q->date=q—>plane;

 cout〈〈"Located!

"〈<endl;

   cout<<”****************”;

    cout<<endl<〈"姓名 :

 ”<<q—〉name;

  cout<

"<<q—>id;

   cout<<endl〈〈”座位号:

"〈seat;

     cout<<endl<<"班机号:

"<<q—>plane;

    cout<

"〈〈q—〉date<〈endl;

   if(x==1){

    cout<〈”删除该纪录?

 [Y/N]";

   cin>>ch;

     if(ch=='Y' || ch=='y') {

       t1=q—>plane;

  t2=q->seat;

       a[t1]、seat[t2]=0;

 a[t1]、seat[0]-—;

        r=q;q=q—>pre;

      r-〉pre—>next=r-〉next;

   if(r—〉next!

=NULL)r—>next-〉pre=r->pre;

   delete(r);

  cout〈〈"**** 记录删除成功!

****";

   write_to_file();

 tempw=wait_head;

       for(i=0;i<wait_head-〉count;i++)

    {

        tempw=tempw—>next;

    if(tempw==NULL)break;

     if((tempw-〉plane==t1)&&(tempw—>seat==t2))

    {

          strcpy(tempw3—>name,tempw—〉name);

         strcpy(tempw3->phone,tempw-〉phone);

      cout〈

"<<endl;

    cout<

"〈

       cout〈<endl<<"ID号:

”<〈tempw-〉id<<endl;

        a[t1]、seat[0]++;

    a[t1]、seat[t2]=1;

      if(tempw->plane==1)add_information(head1,1,tempw-〉seat);

        if(tempw->plane==2)add_information(head2,2,tempw->seat);

    if(tempw->plane==3)add_information(head3,3,tempw->seat);

         tempw2=tempw—〉pre;

    tempw2—>next=tempw->next;

          if(tempw—>next==NULL)wait_end=tempw2;

      else tempw—>next->pre=tempw2;

      delete(tempw);

            wait_head—>count-—;

     write_to_file();

           cout〈phone<<”通知了”〈

     break;

      }

         }

   }

     }continue;

 }

  else

  {

 if(q==NULL)

  {

 step++;

   if(step==2)q=head2;

   if(step==3) q=head3;

    if(step==4){cout〈

    }

 }

 }while

(1);

boolp(node*x,node*y)

 node*p,*q;

  inti,j,k;

 p=x;

 q=y;

  i=j=0;

 do

 {

     while ((p—>name[i]!

= q—>name[j])&&(p—>name[i]!

='\0’)) i++;

  if(p—〉name[i]=='\0'){return(false);break;}

else 

  {

     k=i

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

当前位置:首页 > 经管营销 > 经济市场

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2