数据结构课程设计-航班查询与检索(含代码、流程图、输出结果)

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

算法与数据结构实验报告航班查询与检索

题目:航班查询与检索

指导老师:

组长:

成员:

一:航班信息的查询与检索

按时间查询:

按站点查询:

二分法查询:

二:

算法分析:程序主要采用结构体链表顺序表队列主要算法:/*航班信息的查询与检索*/

三:/*航班信息的查询与检索*/

#include

#include

#include

#define N 6 //航班数

//航班信息

typedef struct flight

{

char flight_number[10]; //航班号

char start_address[10]; //起飞站

char arrived_address[10]; //终点站

char work_date[10]; //班期

char start_time[6]; //起飞时间

char arrived_time[6]; //到达时间

char FlightType[4]; //机型

int fare; //票价

}DataType;

struct flight Flight[N];

//-----------按航班号进行基数排序-----------

typedef char KeyType;

#define D 7 // D为排序码的最大位数

#define R 'a' // R为基数,这里为小于字母'a'代表的整型值struct Node; //单链表结点类型

typedef struct Node RadixNode;

struct Node

{

KeyType key[D]; //关键字

DataType info; //数据信息

RadixNode *next;

};

typedef RadixNode * RadixList;

typedef struct QueueNode

{

RadixNode *f; //对列的头指针

RadixNode *e; //对列的尾指针

}Queue;

Queue queue[R];//用队列表示桶

void radixSort(RadixList * plist, int d, int r)

{

int i,j,k;

RadixNode *p, *head;

head=(*plist)->next;

for(j=d-1; j>=0; j--) //进行d次分配和收集

{

p=head;

for(i=0; i

{

queue[i].f=NULL; queue[i].e=NULL; //清队列

}

while(p!=NULL)

{

k=p->key[j]; //按排序码的第j个分量进行分配

if(queue[k].f==NULL) queue[k].f=p; // 若第k个堆为空,则当前记录为队头

else (queue[k].e)->next=p; // 否则当前记录到第k队的队尾

queue[k].e=p;

p=p->next;

}

i=0;

while(queue[i].f==NULL) i++; // 从r个队列中找出第一个非空的队列

p=queue[i].e; head=queue[i].f; //head为收集链表的头指针

for(i++; i

if(queue[i].f!=NULL)

{ p->next=queue[i].f; p=queue[i].e; } // 收集非空队列

p->next=NULL;

}

(*plist)->next=head;

}

//初始化航班信息

struct Node element[N+1]={

" "," "," "," "," "," "," "," ",0,NULL,//表头

"CA1544","CA1544","","","1245 ","10:55","12:40","733",960,NULL,

"MU5341","MU5341","","","每日","14:20","16:15","M90",1280,NULL,

"CZ3869","CZ3869","","","246 ","08:55","10:35","733",1010,NULL,

"MU3682","MU3682","","","23467","20:50","22:15","M90",1380,NULL,

"HU1836","HU1836","","","每日","09:40","11:20","738",1250,NULL,

"CZ3528","CZ3528","","","13457","15:10","16:50","CRJ",1060,NULL,

};

//------------信息显示------------

//按表的格式输出某个航班信息

//显示头部信息

void Cout_info1()

{

cout<<" ****************************************\n"<

cout<<" * 欢迎您使用*\n"<

cout<<" * 航班信息表*\n"<

cout<<" ****************************************\n"<

cout<<" 航班号起飞时间到达时间起飞站终点站班期机型票价\n"<

相关文档
最新文档