数据结构课程设计之飞机订票系统

上传人:壹****1 文档编号:507605842 上传时间:2022-09-25 格式:DOC 页数:6 大小:31KB
返回 下载 相关 举报
数据结构课程设计之飞机订票系统_第1页
第1页 / 共6页
数据结构课程设计之飞机订票系统_第2页
第2页 / 共6页
数据结构课程设计之飞机订票系统_第3页
第3页 / 共6页
数据结构课程设计之飞机订票系统_第4页
第4页 / 共6页
数据结构课程设计之飞机订票系统_第5页
第5页 / 共6页
点击查看更多>>
资源描述

《数据结构课程设计之飞机订票系统》由会员分享,可在线阅读,更多相关《数据结构课程设计之飞机订票系统(6页珍藏版)》请在金锄头文库上搜索。

1、青岛理工大学 数据结构课程设计报告 题目 飞机订票系统 院系 学生姓名: 班级 学号 起迄日期: 指导教师: 20212021年度 第 2 学期 指导教师评语 成绩 签名 年 月 日 一、需求分析 1.问题描述 设计一个模拟飞机订票系统通过此系统可以录入、查询、修改航班情况完成用户订票和退票功能并且可以保存客户和航班的资料。 2.根本功能 1 录入航班信息。 没个航班的信息包括航班号起飞、抵达城市座位总数剩余座位数。数据由使用者输入。 数据存储在txt文件中采用线性表的链式结构。 2 加载航班和客户信息。 可以自动加载保存在txt文件中的航班和客户的信息。 3 查询航班。 可以通过输入航班号查

2、询该航班的所有信息。 可以通过输入起飞抵达的城市查询航班的信息。 4 订票。 客户的信息包括姓名证件号所订票的航班号座号。 用户输入要订票的航班号如果该航班未满那么订票成功并记录客户的信息。如果该航班已满那么订票失败输出所有未满的航班信息供用户选择。 5 退票。 删除退票用户的订票信息相应的航班的剩余票数增加1。 6 修改航班信息。 用户输入要修改的航班号和要修改的内容修改该航班的相应信息。 7 保存操作。 把当前的航班信息和用户信息分别保存在txt文件中。 8 输出所有客户信息。 按一定的格式输出用户的姓名证件号码航班号座号。 9 输出所有航班信息。 按一定的格式输出所有的航班的航班号起飞抵

3、达城市座位总数剩余座位数。 0 退出系统。 3.输入输出 在控制台下根据提示输入要完成功能的标号然后在提示下选择性的输入航班号、起飞抵达地、证件号码或者姓名等。系统会根据用户的输入输出相应的航班信息或者用户信息。 二、 概要设计 1.设计思路 对于航班和用户分别定义不同的数据结构并且采用线性表的链式结构进行存储。然后根据要完成的功能分模块用函数实现。 所用到的算法主要有链表的创立增加遍历插入删除。 2.数据结构设计 采用的逻辑结构是线性结构。存储结构是链式结构。 /航线结构体。 typedef struct airline char line_num10/航班号 char start_plac

4、e20/起飞地 char end_place20/目的地 int total/座位总数 int left/剩余座位 struct airline next/下一个结点 airline /航线结构体的头结点。 typedef struct airlinehead int count airline next airlinehead /客户结构体 typedef struct client char name20/顾客名 char id10/顾客证件号 char line_num10/航班号 int seat_num/座位号 struct client next/下一个结点 client /客户结

5、构体的头结点。 typedef struct clienthead int count client next clienthead 采用线性链表的原因1航班情况和客户信息与均成线性与线性表的结构相符合。2由于本系统对数据的插入和删除较频繁所以更适合链式存储结构。 3.软件结构设计 /对航班的操作/ airlinehead importint nairlinehead pheadline/录入航班函数n为所要录入航班的数量 airline queryairlinehead phead /查询航班情况 void display_lineairline node/打印一个航班结点的所有信息到屏幕

6、void display_all_lineairlinehead headline/打印所有航班的信息到屏幕 int change_lineairlinehead headline/修改航班信息。 void display_left_airlineairlinehead headline/输出未售完票的航班的信息 /对客户的操作/ void display_clientclient nodeNULL/打印一个客户节点的信息到屏幕。 void display_all_clientclienthead headclient/打印所有客户信息到屏幕。 int bookticketairlinehea

7、d headlineclienthead headclient/订票 int returnticketairlinehead headlineclienthead headclient/退票。 /对文件的操作/ int savemessageairlinehead headlineclienthead headclient/保存航班和客户的信息到相应的txt文件中。 int loadmessageairlinehead headlineclienthead headclient/加载保存在文件中的信息。 模块之间的关系框图 主函数main录入航班信息Import加载航班信息loadmessag

8、e查询航线信息query客户订票bookticket客户退票Returnticket保存操作Sabemessage输出所有航班信息display_all_line输出所有客户信息display_all_client 三、 详细设计 1. 定义程序中所有用到的数据及其数据结构及其根本操作的实现 /航线结构体。 typedef struct airline char line_num10/航班号 char start_place20/起飞地 char end_place20/目的地 int total/座位总数 int left/剩余座位 struct airline next/下一个结点 air

9、line /航线结构体的头结点。 typedef struct airlinehead int count airline next airlinehead /客户结构体 typedef struct client char name20/顾客名 char id10/顾客证件号 char line_num10/航班号 int seat_num/座位号 struct client next/下一个结点 client /客户结构体的头结点。 typedef struct clienthead int count client next clienthead 2主函数和其他函数的算法 /主函数/ v

10、oid main airlinehead headline new airlinehead headline-gtcount0 headline-gtnextNULL clienthead headclient new clienthead headclient-gtcount0 headclient-gtnextNULL while1 main_menu int n coutltltquot请选择您老人家要进行的操作: quot cingtgtn coutltltendl switchn case 1: int num coutltltquot请选择您老人家要录入的航班的数目 quot ci

11、ngtgtnum coutltltendl importnumheadline coutltltendl /display_all_lineheadline coutltltquot航班信息成功录入。quot coutltltendlltltendl break case 2: loadmessageheadlineheadclient break case 3: airline find findqueryheadline iffind display_linefind break case 4: bookticket headlineheadclient /display_all_clie

12、ntheadclient break case 5: returnticketheadlineheadclient break case 6: savemessageheadlineheadclient break case 7: display_all_lineheadline break case 8: display_all_clientheadclient break case 0: exit1 break /订票函数的实现/ int bookticketairlinehead headlineclienthead headclient /订票 coutltltquot请输入航班号 q

13、uot char line_num10 cingtgtline_num airline temp tempheadline-gtnext whiletemp ifstrcmptemp-gtline_numline_num0 break temptemp-gtnext iftemp coutltltquot未找到该航班quotltltendl return 0 iftemp-gtleft0 coutltltquot对不起该航班票已经售完。quotltltendl coutltltquot请选择其他适宜的航班quot client customnew client coutltltquot请输入你

14、的证件号码 quot cingtgtcustom-gtid coutltltendl coutltltquot请输入你的姓名quot cingtgtcustom-gtname coutltltendl custom-gtseat_numtemp-gttotal - temp-gtleft 1 custom-gtnextNULL strcpycustom-gtline_numline_num temp-gtleft- headclient-gtcount custom-gtnext headclient-gtnext headclient-gtnext custom coutltltquot订票

15、成功祝您旅途愉快。quot return 1 /退票函数的实现/ int returnticketairlinehead headlineclienthead headclient/退票。 coutltltquot请输入顾客的证件号码id: quot char id10 cingtgtid airline airlinetemp headline-gtnext client clienttemp headclient-gtnext ifNULLairlinetemp coutltltquot当前没有航班信息。quotltltendl return 0 char line_num10 clien

16、t delnext ifstrcmpclienttemp-gtidid0/要删除的节点为第一个时。 strcpyline_numclienttemp-gtline_num headclient-gtnextclienttemp-gtnext delete clienttemp whileairlinetemp/修改对票客户所对应的航班的售票信息。 ifstrcmpline_numairlinetemp-gtline_num 0 airlinetemp-gtleft break airlinetemp airlinetemp-gtnext coutltltquot退票成功生意不成仁义在有时机继续合作。quot return 1 whileclienttemp-gtnext/要删除 的节点不是第一个时。 ifstrcmpclienttemp-gtnext-gtidid0 strc

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 商业/管理/HR > 商业计划书

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号