第一范文网 - 专业文章范例文档资料分享平台

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

来源:用户分享 时间:2025/8/24 7:18:37 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

.

cout<

//--------------信 息 复 制---------------- //将排好的序列(链表)转化成顺序表存储形式 void copy(flight F[],Node element[]) {

RadixList p=element; p=p->next; int i;

for(i=0;i

strcpy(F[i].flight_number,p->info.flight_number); strcpy(F[i].start_time,p->info.start_time); strcpy(F[i].arrived_time,p->info.arrived_time); strcpy(F[i].start_address,p->info.start_address); strcpy(F[i].arrived_address,p->info.arrived_address); strcpy(F[i].work_date,p->info.work_date); strcpy(F[i].FlightType,p->info.FlightType); F[i].fare=p->info.fare; p=p->next; } }

//---------------服 务 菜 单-------------- void F_By_Time(flight F[],int); void F_By_Address(flight F[],int); void F_By_fare(flight F[]); void F_By_FN(flight F[]); //主菜单

void mainmenu() { char ch; int y;

cout<<\ 主菜单\\n\ cout<<\

===========================================================\\n\ cout<<\ Please choose: (input the number)(输入查询/排序命令)\\n\ cout<<\ 0. show the mainmenu (显示主菜单)\\n\ cout<<\ 1. Find by flight number(按航班号查询)\\n\ cout<<\ 2. Find by start time(按起飞时间查询)\\n\ cout<<\ 3. Find by arrived time(按到达时间查询)\\n\ cout<<\ 4. Find by start address(按起飞地点查询)\\n\ cout<<\ 5. Find by arrived address(按目的地点查询)\\n\

'.

.

cout<<\ 6. Find by the fare(按票价范围查询)\\n\

cout<<\ ----其他键退出\ cout<<\

===========================================================\\n\ while(1) {

cout<<\请输入服务命令:\ cin>>y; switch(y) {

case 0: mainmenu();break; case 1:F_By_FN(Flight);break;

case 2:F_By_Time(Flight,1);break; case 3:F_By_Time(Flight,2);break; case 4:F_By_Address(Flight,1);break; case 5:F_By_Address(Flight,2);break; case 6:F_By_fare(Flight);break;

default :cout<<\ \ }

cout<<\是否退出?(Y/N):\ cin>>ch;

if(ch=='Y'||ch=='y') break; } }

//--------------查 询 系 统-------------- //通过航班号实现二分查找法查找 void F_By_FN(flight F[]) {

int low=0,high=N,mid; char Num[10];

cout<<\请输入您要查询的航班号:\ cin>>Num;

Cout_info1();//显示头部信息 while(low<=high) {

mid=(low+high)/2;

if(strcmp(Num,F[mid].flight_number)==0) {Cout_info2_2(F,mid);break;} else if(strcmp(Num,F[mid].flight_number)<0) high=mid-1; else low=mid+1; }

cout<<\ *************对不起,没有您要查找的航班号********** }

'.

谢谢惠顾! \

//通过起飞/到达时间查询

void F_By_Time(flight F[],int Time) { int i; char T[6];

cout<<\请输入您要查询的航班的起飞/抵达时间:\ cin>>T;

Cout_info1();//显示头部信息 for(i=0;i

if(Time==1) //按起飞时间查询 {

if(strcmp(T,F[i].start_time)==0) Cout_info2_2(F,i); }

if(Time==2) //按抵达时间查询 {

if(strcmp(T,F[i].arrived_time)==0) Cout_info2_2(F,i); } }

cout<<\ *******对不起,该时间没有航班******* \}

//通过站点查询

void F_By_Address(flight F[],int AD) {

char str[10];

cout<<\请输入您要查询的航班的起飞/抵达地址:\ cin>>str; Cout_info1(); for(int i=0;i

if(AD==1) //按起点站查询 { if(strcmp(str,F[i].start_address)==0) Cout_info2_2(F,i);

} if(AD==2) //按目的站查询

{ if(strcmp(str,F[i].arrived_address)==0) Cout_info2_2(F,i); }

}

cout<<\ ********对不起,该站点不存在******** }

'.

.

\

.

//通过票价范围查询

void F_By_fare(flight F[]) {

int T1,T2,i;

cout<<\请输入您要查询的航班的最低票价(单位:元):\ cin>>T1;

cout<<\请输入您要查询的航班的最高票价(单位:元):\ cin>>T2;

Cout_info1(); for(i=0;i

if(T1<=F[i].fare && T2>=F[i].fare) Cout_info2_2(F,i); }

cout<<\ *******对不起,没有适合您的航班,请修改您的票价范围********\}

//--------------主 函 数---------------- int main() {

RadixList p=element; for(int i=0;i

element[i].next=&element[i+1]; element[10].next=NULL; radixSort(&p, D, R); //基数排序

output_ALL_info1(element); //输出排序后的有序序列(航班信息) copy(Flight,element); //另存储排序后的航班信息 mainmenu(); //给出主菜单 return 0; }

测试数据及测试结果:

'.

数据结构课程设计-航班查询与检索(含代码、流程图、输出结果).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c1vt3k3gmhh1lh1d7s0l19lpyv23wwc008mz_3.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top