三九宝宝网宝宝百科宝宝知识

求C语言编程航班信息查询与检索

12月27日 编辑 39baobao.com

[了解航班情况旅游英语口语]旅游英语口语:航班情况A:Is it a direct flight?是直达的吗?B:Yes,its a non-stop.是,是直达的。How many flights are there to Shanghai every day?每天有多少次航班飞往上...+阅读

#include "stdio.h"#include "malloc.h"#include "string.h"#define MAXN 100 typedef struct{ char hour[MAXN]; char minute[MAXN]; } time; typedef struct node { char number[MAXN]; //航班号 time start; //起飞时间 time end; //到达时间 char start_station[MAXN]; //起点站 char end_station[MAXN]; //终点站 char type[MAXN]; //飞机型号 char price[MAXN]; //票价 struct node*link; }NODE; NODE *create_link_list(int n) { int i; NODE *head,*p,*q; if(n==0)return(NULL); head=(NODE*)malloc(sizeof(NODE)); for(i=0;i { head->number[i]='\0'; head->start.hour[i]='\0'; head->start.minute[i]='\0'; head->end.hour[i]='\0'; head->end.minute[i]='\0'; head->start_station[i]='\0'; head->end_station[i]='\0'; head->type[i]='\0'; head->price[i]='\0'; } p=head; for(i=1;i { printf("请输入航班号:"); scanf("%s",&(p->number)); printf("请输入起飞时间(时 分):"); scanf("%s %s",&(p->start.hour),&(p->start.minute)); printf("请输入达到时间(时 分):"); scanf("%s %s",&(p->end.hour),&(p->end.minute)); printf("请输入起点站 终点站:"); scanf("%s %s",&(p->start_station),&(p->end_station)); printf("请输入飞机型号:"); scanf("%s",&(p->type)); printf("请输入票价:"); scanf("%s",&(p->price)); printf("\n"); q=(NODE*)malloc(sizeof(NODE)); p->link=q; p=q; } printf("请输入航班号:"); scanf("%s",&(p->number)); printf("请输入起飞时间(时 分):"); scanf("%s %s",&(p->start.hour),&(p->start.minute)); printf("请输入达到时间(时 分):"); scanf("%s %s",&(p->end.hour),&(p->end.minute)); printf("请输入起点站 终点站:"); scanf("%s %s",&(p->start_station),&(p->end_station)); printf("请输入飞机型号:"); scanf("%s",&(p->type)); printf("请输入票价:"); scanf("%s",&(p->price)); printf("\n"); getchar(); p->link=NULL; return(head); } void insert(NODE **p_head,NODE *q) { NODE *p; if(*p_head==NULL)*p_head=q; else { p=*p_head; while(p!=NULL&p->link!=NULL) p=p->link; p->link=q; } } unsigned int countit(NODE* n)//计算链表长度 { unsigned int counti = 0; while(n!=NULL) counti++,n=n->link; return counti; } NODE* getindex(NODE* head, int num); NODE* getindex(NODE* head, int num)//取得index为num 的节点!{ if(numcountit(head)) return NULL; NODE* rn = head; while(--num>0) rn = rn->link; return rn; } int binSearch(NODE* n,char *strinput,int low, int high)// 二分查找 { int i; int middle = (high+low)/2; if (high return 0; if ((i=strcmp(strinput, n->number)) high= middle; else if (i >0) low = middle; else { i = middle; return i; } binSearch(getindex(n,middle),strinput,low,high); } int bisect(char a[],int n,char s[MAXN])//二分查找 { int i,j,m; i=0; j=n-1; while(i { m=(i+j)/2; } return(-1); } NODE *search1(NODE *head,char v[MAXN])//起点站顺序查找 { for(;head!=NULL&strcmp(head->start_station,&v[0]);head=head->link); return(head); } NODE *search2(NODE *head,char w[MAXN])//到达站顺序查找 { for(;head!=NULL&strcmp(head->end_station,&w[0]);head=head->link); return(head); } NODE *search3(NODE *head,char x[MAXN],char y[MAXN])//起飞时间顺序查找 { for(;head!=NULL&(strcmp(head->start.hour,&x[0]) || strcmp(head->start.minute,&y[0]));head=head->link); return(head); } NODE *search4(NODE *head,char t[MAXN],char u[MAXN])//到达时间顺序查找 { for(;head!=NULL&(strcmp(head->end.hour,&t[0]) || strcmp(head->end.minute,&u[0]));head=head->link); return(head); } void output(NODE *p) { while(p!=NULL) { printf("航班信息:\n"); printf("航班号:%s\n",p->number); printf("起飞时间:%s点%s分,",p->start.hour,p->start.minute); printf("到达时间:%s点%s分\n",p->end.hour,p->end.minute); printf("起点站:%s,",p->start_station); printf("到达站:%s\n",p->end_station); printf("飞机型号:%s ",p->type); printf("票价:%s元\n\n",p->price); p=p->link; } } NODE *rank( NODE *head) { NODE *q=0,*p=0,*t,*h1; h1=head->link; head->link=NULL; while(h1!=NULL) { t=h1; h1=h1->link; p=head; q=head; while( p!=NULL & strcmp(t->number, p->number)>0 ) { q=p; p=p->link; } if(q == p) { t->link=p; head=t; } else { t->link=p; q->link=t; } } return head; } int main(int argc, char* argv[]) { NODE *p,*q,*r; int a,b,i,j,n; int count=0; char o[MAXN]; char s[MAXN]; char v[MAXN]; char w[MAXN]; char x[MAXN]; char y[MAXN]; char t[MAXN]; char u[MAXN]; for(i=0;i { o[i]='\0'; s[i]='\0'; v[i]='\0'; w[i]='\0'; x[i]='\0'; y[i]='\0'; t[i]='\0'; u[i]='\0'; } while(true) { printf("【航班信息的查询与检索】\n"); printf("★*******************************★\n"); printf(" 1.建立航班信息\n"); printf(" 2.插入航班信息\n"); printf(" 3.按航班号进行排序 \n"); printf(" 4.航班信息查询\n"); printf(" 5.显示...

以下为关联文档:

航班号是BA038The flight number is BA 038.航班号是BA 038.A: I'm going to the airport tomorrow. My wife's arriving from London.A: 我明天要去机场。我妻子从伦敦来。B: I hope...

三招应对航班延误坐飞机的人,都遇到过航班延误的情况,尤其是在“天气”越来越不好的今天。看着机场大厅内熙熙攘攘等候航班的人群,“航班延误”似乎已经变得越来越正常。难道我们只能任其扰乱自...

订机票预定航班的英语口语14句1.Do I he to make a reconfirmation? 我还要再确认吗? 2.Is there any earlier one? 还有更早一点的吗? 3.Could you tell me my reservation number, please? 请你告诉我我...

分段函数c语言编程实验报告 1、有一分段函数: 设计一程序完成, 主控函数main()输入X的值并输出Y值.函数VAL计算Y的值。 1.需求规格说明 本题要求掌握C语言的数据类型,程序结构,基本输出输入,函数应...

国内航班免费随身携带的行李重量的上限是多少1、随身携带行李的限制规定 ⑴、乘坐国内航班:旅客的手提行李总重量不要超过5公斤,体积每件行李不超过20*40*55厘米(根据各航空公司要求不同可能有所不同)。安检现场有供旅客测...

首都航空国际航班行李托运可免费2件吗1. 不能,只能免费一件。并且免费托运行李限额为20公斤,经济舱持学生护照的旅客,可以免费托运的行李限额为30公斤;公务舱免费托运行李限额为30公斤;头等舱免费托运行李限额为40公...

c语言编程:打印年历#include void main() { int i,j,k,year,week; int day[]=; char month[12][10]=; printf("Input year you want to print:"); scanf("%d",&year); if((year%4==0&year%100!=0)|...

乘坐亚洲航空的航班行李具体是怎么规定的?限重多少?怎么缴费亚航行李托运规定: 每件托运行李不得超过81厘米(高)x 119厘米(宽)x 119厘米(长),重量不得超过32公斤。 可在线预订的托运行李重量 国内航班 – 15公斤/ 20公斤/ 25公斤/ 30公斤/ 40...

推荐阅读
图文推荐