資源簡介
飛機訂票系統 請設計一個飛機票訂票和退票系統。假設某民航機場有m個航次的班機,每個航次都只到達一個目的地,試為該機場售票處設計一個自動訂票和退票系統。 該系統需要實現以下功能: (1) 訂票:若該航次余票數大于等于客訂票數,則在該航次的乘客表(按乘客姓氏字母詞典順序排列)中,插入訂票乘客的信息項

代碼片段和文件信息
//飛機訂票退票系統,請先閱讀使用說明!!!!!!??
//1、打開.exe文件進入主菜單。
//2、管理員先進入“5.管理操作”進行各項設置!!!
//3、第一次進入管理操作需要先設置密碼;
//4、管理員請記住密碼,以后進入管理操作都需要這個密碼;
//5、先進入“1、設置航班信息;”設置各項航班信息;
//6、設置完以后請選擇“7、退出管理操作,返回主菜單;”
//7、注意:“8、退出系統(所有數據丟失!!!)。”
//8、請按菜單提示操作。
#include
#include
#include
#include?
#include
using?namespace?std;
string?password;
struct?flight
{flight?*next;//指針
?string?f;????//飛機航次
?int?max;?????//總票數
?int?remain;??//余票數
};
struct?passenger
{passenger?*next;
?string?name;//乘客名字
?string?fli;
?int?ticket1;//此乘客本次訂票數
?int?ticket2;//此乘客已訂票數
?int?refund;//退票數
};
int?choice()//確定操作
{string?ch;
??cout<<“確定輸入信息?\n“<<“y/n???“;cin>>ch;
A:?if(ch==“y“)return?1;
???if(ch==“n“)return?0;
????else?{cout<<“y/n???“;cin>>ch;goto?A;}}
int?displayp(string&sint?i)?//密碼顯示為*號,用13判斷是不是回車??
{string?a=s;
?char?ch;
?ch=getch();s+=ch;
?if(ch==13&&i==1){s=a;return?0;}//回車退出
?if(ch!=13)cout<<“*“;
?do
?{ch=getch();
??s+=ch;
??if(ch==13)break;
??cout<<“*“;????
?}while(ch!=13)?;
?cout<
int?setpassword()//密碼操作
{int?ij;
?string?password2;
?if(password==““)
?{cout<<“請設置管理員密碼:(退出請輸入‘回車‘)“;j=1;i=displayp(passwordj);if(i==0)return?0;
??cout<<“再次確認:“;j=0;i=displayp(password2j);if(i==0)return?0;
??while(password2!=password)
??{password=““;
???password2=““;
???cout<<“兩次輸入的密碼不一樣,請再次設置!“< ???cout<<“請設置管理員密碼:(退出請輸入‘回車‘)“;j=1;i=displayp(passwordj);if(i==0)return?0;
???cout<<“再次確認:“;j=0;i=displayp(password2j);if(i==0)return?0;}
???cout< ?else?{string?const?password3=password;
???????cout<<“請輸入管理員密碼:(退出請輸入‘回車‘)“;
???????i=displayp(password20);if(i==0)return?0;
???????while(password!=password2)
???{password=password3;
????password2=““;
????cout<<“密碼錯誤!請重新輸入:(退出請輸入‘回車‘)“;
????i=displayp(password20);if(i==0)return?0;};
???cout<
void?show(flight*head)//顯示航班信息
{cout<<“\n各航班信息:\n“< ?cout<<“??航班名稱???“<<“總座位數????“<<“剩余票數???“< ?while(head)
?{cout<f<max<remain< ??head=head->next;}
?cout<
int?setflight1(flight*&head)//管理員輸入航班信息子函數,建立鏈表
{flight?*s*p;
?if(head){cout<<“您已經設置了航班信息!“< ?s=new?flight;
?cout<<“全部輸入結束后請輸入‘end‘!“< ?p=s;
?cout<<“請輸入航班名稱:??????????“;cin>>s->f;
?if(s->f!=“end“){
?cout<<“請輸入此航班的最大容客量:“;
?????cin>>s->max;
?while(cin.fail()||s->max<=0){
?????????cin.clear();cin.ignore();
?cout?<“請輸入一個正整數!“;
?????????cin>>s->max;}
?s->remain=s->max;}
?while(s->f!=“end“)
?{if(head==NULL)head=s;
??else?p->next=s;
??p=s;s=new?flight;
??cout<<“請輸入航班名稱:??????????“;cin>>s->f;
??if(s->f!=“end“){
??cout<<“請輸入此航班的最大容客量:“;
??cin>>s->max;
??while(cin.fail()||s->max<=0){
??cin.clear();cin.ignore();
??cout?<“請輸入一個正整數!“< ??????????cin>>s->max;}
??s->remain=s->max;}}
?p->next=NULL;
?delete?s;
?return?0;}
void?amend(flight*&head)//修改航班信息
{int?i;
?string?key;
?if(!head){cout<<“您還沒有設置航
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????20936??2009-04-04?21:48??飛機訂票系統-數據結構作業.cpp
?????文件????????717??2009-10-09?11:55??需求.txt
-----------?---------??----------?-----??----
????????????????21653????????????????????2
- 上一篇:SLR1分析表的生成
- 下一篇:C++ 小型編譯器
評論
共有 條評論