2022年用单链表编制一个简单的火车票销售系统程序代码 .pdf
《2022年用单链表编制一个简单的火车票销售系统程序代码 .pdf》由会员分享,可在线阅读,更多相关《2022年用单链表编制一个简单的火车票销售系统程序代码 .pdf(6页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、用单链表编制一个简单的火车票销售系统,可完成售票、退票、车票剩余情况查询等功能。每张车票包含车次、座位等信息。要求:在售票、退票、查询剩余票等环节中,都必须显示出车票的信息, 即车次、 座位情况。 为简单起见, 在此假设所有出售的车票均为同一车次的车票。退票时,必须是车站售出的列车票才能退(这里以同一车次的为例),否则视为无效票,不能办理退票业务。#include #include #define ShowCommand(x) cout (x) endl usingnamespace std; typedef struct tagTicket int nCheCi; / 车次int nNumb
2、er; / 座号Ticket; typedef struct tagTicketNode Ticket ticket; tagTicketNode* pNextTicket; TicketNode; typedef TicketNode * TicketList; TicketList gTicketList; void ShowAllTickets(); bool InitTicketsList(); void BuyTicket(); int GetTicketCount(); int main() gTicketList = new TicketNode; / initiall Tick
3、ets list if (!InitTicketsList() cout tickets initialize failed endl; return0; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 6 页 - - - - - - - - - cout Please input command iCommand; while (iCommand != 0) ShowCommand(iCommand); switch (iCommand) case 0: / break
4、; case 1: / Show All Tickets; ShowAllTickets(); break; case 2: / buy a ticket BuyTicket(); break; case 3: cout current tickets count is =GetTicketCount() endl; default : /assert(false); break; cout Please input command 0: exit , 1: buy, 2: iCommand; return0; void ShowAllTickets() TicketNode* tmpTick
5、Node = gTicketList; for ( int i =1; i 5; i+) cout ticket.nNumber pNextTicket; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 6 页 - - - - - - - - - bool InitTicketsList() gTicketList-ticket.nCheCi = 100; gTicketList-ticket.nNumber = 0; TicketNode* nextTicket= ne
6、w TicketNode; gTicketList-pNextTicket = nextTicket; for ( int i =1; iticket.nCheCi = 100; nextTicket-ticket.nNumber = i; nextTicket-pNextTicket = new TicketNode; nextTicket = nextTicket-pNextTicket; nextTicket-pNextTicket = NULL; returntrue ; void BuyTicket() gTicketList = gTicketList-pNextTicket; r
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年用单链表编制一个简单的火车票销售系统程序代码 2022 年用单链表 编制 一个 简单 火车票 销售 系统 程序代码
限制150内