資源簡(jiǎn)介
飛機(jī)訂票系統(tǒng) 請(qǐng)?jiān)O(shè)計(jì)一個(gè)飛機(jī)票訂票和退票系統(tǒng)。假設(shè)某民航機(jī)場(chǎng)有m個(gè)航次的班機(jī),每個(gè)航次都只到達(dá)一個(gè)目的地,試為該機(jī)場(chǎng)售票處設(shè)計(jì)一個(gè)自動(dòng)訂票和退票系統(tǒng)。 該系統(tǒng)需要實(shí)現(xiàn)以下功能: (1) 訂票:若該航次余票數(shù)大于等于客訂票數(shù),則在該航次的乘客表(按乘客姓氏字母詞典順序排列)中,插入訂票乘客的信息項(xiàng)

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