项目要求

  1.已经给出链表定义(本系统用双链表实现更为方便,但是由于要求用单链表,所以按照规定做事)

  2.信息录入(当然是添加航班与取消航班了)

  3.按照起飞时间先后顺序排列(可以在插入时即顺序插入,但为了体现排序过程,封装成了排序函数)

  4.可根据不同关键字进行查询(实现了三种具有代表性的查询方案:航班号查询(结果唯一),起点站查询(结果不唯一),路线查询(最常用))

 


 

实现

头文件

 1 //@ author 成鹏致远
 2 //@ net http://infodown.tap.cn
 3 //@ qq 552158509
 4 //@ blog lcw.cnblogs.com
 5 
 6 #ifndef __FLIGHT_H
 7 #define __FLIGHT_H
 8 
 9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <stdbool.h>
12 #include <string.h>
13 
14 typedef struct flight
15 {
16     char number[10];//航班号
17     char staddress[20];//起站点
18     char arraddress[20];//终点站
19     char date[10];//班期
20     char type[4];//机型
21     int stime;//起飞时间
22     int atime;//到达时间
23     int value;//标价
24 }datatype;
25 
26 typedef struct node
27 {
28     datatype info;
29     struct node *next;
30 }node_list,*p_node_list;
31 
32 
33 extern void flight_manage(p_node_list phead);//航班管理
34 extern void flight_add(p_node_list phead);//添加航班
35 extern p_node_list in_number(p_node_list phead, char *);//通过航班号查询航班,有则返回指向航班的前一个节点的指针(删除节点时方便操作)
36 extern void flight_cancel(p_node_list phead);//取消航班
37 extern void flight_show(p_node_list phead);//显示航班信息
38 extern void flight_search(p_node_list phead);//查询航班信息
39 
40 extern void list_init(p_node_list *phead);//链表头初始化
41 extern void keep_scren();//保持界面
42 extern void flight_sort(p_node_list phead);//按起飞时间排序
43 
44 extern void flight_print(p_node_list pnode);//打印pnode指向的结点的航班信息
45 
46 
47 
48 
49 extern void flight_search(p_node_list phead);//查询航班信息
50 extern void search_by_number(p_node_list phead, char *num);//航班号查询
51 extern void search_by_saddr(p_node_list phead, char *saddr);//起点站查询
52 extern void search_by_line(p_node_list phead, char *saddr, char *daddr);//航线查询
53 
54 
55 
56 #endif
View Code

相关文章:

  • 2021-07-07
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2021-09-23
  • 2021-09-12
  • 2021-11-11
  • 2021-12-08
猜你喜欢
  • 2021-04-14
  • 2021-11-17
  • 2021-12-24
  • 2021-09-06
  • 2022-02-15
  • 2022-01-07
  • 2022-01-13
相关资源
相似解决方案