C++實(shí)現(xiàn)班車管理系統(tǒng)課程設(shè)計(jì)
本文實(shí)例為大家分享了C++實(shí)現(xiàn)班車管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
課程設(shè)計(jì)要求:
一交通公司,班車系統(tǒng)的數(shù)據(jù)包括如下兩部分:
①班車信息:班交及車號(hào)、最大載客數(shù)、起點(diǎn)、開車時(shí)間、終地點(diǎn)、到達(dá)終點(diǎn)站時(shí)間,單價(jià);
② 乘客信息:車次及車號(hào)、身份證號(hào)碼、姓名、性別、出生年月、座位號(hào)。
乘客訂票的主要方式是:乘客提供起點(diǎn)、時(shí)間、終點(diǎn)、訂票數(shù)等訂票要求,根據(jù)事先保存的班數(shù)據(jù)決定乘客能否訂票?只有全部滿足了乘客的訂票要求并且所訂班次有足夠的未訂座位之后才能完成訂票處理,并且修改該班次的未訂座位數(shù)(每個(gè)班的未訂座位數(shù)的初始值就是該班次的最大載客數(shù));否則,訂票失敗,并且給出不能訂票的原因。
功能要求 :
1、增加班次記錄。
2、班次取消。
3、班次查詢。
4、班次訂票。
5、設(shè)計(jì)一個(gè)菜單,至少具有上述操作要求的基本功能。
程序:
// kcsjbcxxcx.cpp : 定義控制臺(tái)應(yīng)用程序的入口點(diǎn)。 // ? #include "stdafx.h" #include<iostream> //#include<dos.h> //#include<time.h> using namespace std; int n=0,m=0; ? struct date { ?? ?int year; ?? ?int month; ?? ?int day; }; struct time { int shi; int fen; int miao; }; struct guanli { char zh[15]; char mima[20]; }guan1={"zd1123xufei","201211632326"},guan2={"minggezhijia","zd2012cjjxx"}; enum beiz { ?? ?售票中,可發(fā)車,班次取消}; enum qid {湛江}; enum zhongd {廣州,深圳,東莞,佛山,揭陽,中山,茂名,汕頭}; struct banche { ?? ?int bianhao;?? ??? ?//編號(hào) ?? ?enum qid qidian;?? ?//出發(fā)地 ?? ?enum zhongd zhongdian;?? ?//終點(diǎn)站 ?? ?int zuoweishu;?? ??? ?//最大載客量 ?? ?int shengyup;?? ??? ?//剩余可載客數(shù) ?? ?struct time fache;?? ?//發(fā)車時(shí)間 ?? ?enum beiz beizhu;?? ?//備注信息:是否可購票和發(fā)車 ?? ?banche *next; }; struct dingpiaoxx { ?? ?char xingming[30]; ?? ?char zheng[19]; ?? ?enum zhongd gpzd; ?? ?struct time shijian; ?? ?struct date riqi; ?? ?int piaoshu; ?? ?dingpiaoxx *NEXT; }; banche *creat(); banche *insert(banche *head,banche *banc); banche *charu(banche *hea); void xiug(banche *hed); banche *del(banche *head); void chache(banche *head); dingpiaoxx *CREAT(); dingpiaoxx *dingpiao(dingpiaoxx *HEAD); void gaip(dingpiaoxx *HEAD); void xiup(dingpiaoxx *HED ); void chapiao(dingpiaoxx *HEAD ); dingpiaoxx ?*tianjia(dingpiaoxx *HEAD); dingpiaoxx *shanc(dingpiaoxx *HEAD ); void welc(); //void chushi(); void xuanze(); void weihu(); void kehu(); int denglu(); /*********************下面是主函數(shù)******************/ int main() { ?? ?char key='y'; ?? ?welc(); ?? ?//chushi(); ?? ?while(key!='n'&&key!='N') ?? ?{ ?? ?xuanze(); ?? ?int a,b; ?? ?cin>>a; ?? ?if(a==1) ?? ?{ ?? ?b=denglu(); ?? ?if(b==1) ?? ?{int gg=1; ?? ?while(gg=1) ?? ??? ?{weihu(); ?? ?cout<<"是否繼續(xù)?1:是 , 2:否 "<<endl; ?? ?cin>>gg; ?? ?}} ?? ?} ?? ?else if(a==2) ?? ?{ ?? ?{int gg=1; ?? ?while(gg=1) ?? ??? ?{kehu(); ?? ?cout<<"是否繼續(xù)?1:是 , 2:否 "<<endl; ?? ?cin>>gg; ?? ?}} ?? ?} ?? ?else ?? ?cout<<"輸入錯(cuò)誤,請(qǐng)按提示信息輸入!"<<endl; ?? ?cout<<"感謝你使用本系統(tǒng)"<<endl ?? ??? ?<<"按“Y”返回身份選擇界面"<<endl ?? ??? ?<<"按“N”退出本系統(tǒng)"<<endl; ?? ?cin>>key; ?? ?} ? ?? ?return 0; } /********************************以下是實(shí)現(xiàn)各種功能的函數(shù)******************/ banche *head=creat(); banche *creat()?? ??? ?//建立班次信息表 { ?? ?int a,b=1; ?? ?char key; banche *head,*p1,*p2; head=NULL; p1=new(banche); p2=p1; cout<<"請(qǐng)輸入班車編號(hào)"<<endl; cin>>p1->bianhao; p1->qidian=qid(0); cout<<"請(qǐng)輸入班車到達(dá)的終點(diǎn)站對(duì)應(yīng)的序號(hào)"<<endl ?? ?<<"0 廣州;1 深圳;2 東莞;3 佛山;4 揭陽;5 中山;6 茂名;7 汕頭"<<endl; cin>>a; p1->zhongdian=zhongd(a); cout<<"請(qǐng)輸入該班次最大乘客數(shù)"<<endl; cin>>p1->zuoweishu; p1->shengyup = p1->zuoweishu; cout<<"請(qǐng)輸入班車出發(fā)時(shí)間(時(shí)、分)"<<endl; cin>>p1->fache.shi >>p1->fache.fen ; p1->beizhu =beiz(0); while(b==1) { n++; if(n==1) ?? ?head=p1; else { ?? ?p2->next=p1; ?? ?p2=p1; } p1=new(banche); cout<<"請(qǐng)輸入班車編號(hào)"<<endl; cin>>p1->bianhao; p1->qidian=qid(0); cout<<"請(qǐng)輸入班車到達(dá)的終點(diǎn)站對(duì)應(yīng)的序號(hào)"<<endl ?? ?<<"0 廣州;1 深圳;2 東莞;3 佛山;4 揭陽;5 中山;6 茂名;7 汕頭"<<endl; cin>>a; p1->zhongdian=zhongd(a); cout<<"請(qǐng)輸入該班次最大乘客數(shù)"<<endl; cin>>p1->zuoweishu; p1->shengyup = p1->zuoweishu; p1->beizhu =beiz(0); cout<<"請(qǐng)輸入班車出發(fā)時(shí)間(時(shí)、分)"<<endl; cin>>p1->fache.shi >>p1->fache.fen ; cout<<"是否繼續(xù),按任意鍵繼續(xù),按N結(jié)束"<<endl; cin>>key; if( key =='n'||key=='N') b=0; else ?? ?b=1; } return head; } banche *insert(banche *head,banche *banc)?? ? { banche *p0,*p1; p1=head; p0=banc; if(head==NULL) { head=p0; p0->next=NULL; } else { ?? ?head=p0; ?? ?p0->next=p1; } n++; return head; } banche *charu(banche *hea)?? ??? ?//添加班次記錄 { ?? ?int a,b=1; ?? ?char key; ?? ?while(b) ?? ?{ banche *banc=new banche; ? cout<<"請(qǐng)輸入班車到達(dá)的終點(diǎn)站對(duì)應(yīng)的序號(hào)"<<endl ?? ?<<"0 廣州;1 深圳;2 東莞;3 佛山;4 揭陽;5 中山;6 茂名;7 汕頭"<<endl; cin>>a; banc->zhongdian=zhongd(a); cout<<"請(qǐng)輸入該班次最大乘客數(shù)"<<endl; cin>>banc->zuoweishu; banc->shengyup = banc->zuoweishu; banc->beizhu =beiz(0); cout<<"請(qǐng)輸入班車出發(fā)時(shí)間(時(shí)、分)"<<endl; cin>>banc->fache.shi >>banc->fache.fen ; head=insert(hea,banc); cout<<"按任意鍵繼續(xù),按“N”結(jié)束添加"<<endl; cin>>key; if(key=='n'||key=='N') ?? ?b=0; } ?? ?return head; } void xiug(banche *hed) { ?? ?banche *p1,*p2,xiu; ?? ?int a,b,c=1; ?? ?cout<<"請(qǐng)輸入要修改的班次編號(hào)"<<endl; ?? ?cin>>xiu.bianhao ; ?? ?p1=hed; ?? ?while(p1!=NULL||p1->bianhao !=xiu.bianhao) ?? ?{ ?? ?p2=p1; ?? ?p1=p1->next ; ?? ?} if(p1==NULL) ?? ?cout<<"沒有這個(gè)班次"<<endl; else ?? ?{ ?? ??? ?while(c==1) ?? ??? ?{ ?? ??? ?cout<<"請(qǐng)輸入要修改的部分對(duì)應(yīng)編號(hào)"<<endl ?? ?<<"1.編號(hào)\t"<<"2.出發(fā)地\t"<<"3.終點(diǎn)站\t"<<"4.最大載客量\t"<<endl ?? ?<<"5.剩余可載客數(shù)\t"<<"6.發(fā)車時(shí)間\t"<<"7.備注信息\t"<<"\t"<<endl; cin>>a; switch (a) { ?? ?case 1: ?? ??? ?cout<<"請(qǐng)輸入新編號(hào)"<<endl; ?? ??? ?cin>>p1->bianhao ; ?? ??? ??? ?break; ?? ?case 2: ?? ??? ?cout<<"不可更改信息"<<endl; ?? ??? ??? ?break; ?? ?case 3: ?? ??? ?cout<<"請(qǐng)輸入新地名對(duì)應(yīng)標(biāo)號(hào)"<<endl ?? ??? ??? ?<<"0 廣州;1 深圳;2 東莞;3 佛山;4 揭陽;5 中山;6 茂名;7 汕頭"<<endl; ?? ??? ?cin>>b ; ?? ??? ?p1->zhongdian=zhongd(b); ?? ??? ??? ?break; ?? ?case 4: ?? ??? ?cout<<"請(qǐng)輸入新班次最大載客量"<<endl; ?? ??? ?cin>>p1->zuoweishu ?; ?? ??? ??? ?break; ?? ?case 5: ?? ??? ?cout<<"請(qǐng)輸入新數(shù)字"<<endl; ?? ??? ?cin>>p1->shengyup ?; ?? ??? ??? ?break; ?? ?case 6: ?? ??? ?cout<<"請(qǐng)輸入新時(shí)間"<<endl; ?? ??? ?cin>>p1->fache.shi >>p1->fache.fen ; ?? ??? ??? ?break; ?? ?case 7: ?? ??? ?cout<<"請(qǐng)輸入新信息:0.售票中,1.可發(fā)車,2.班次取消"<<endl; ?? ??? ?cin>>b ; ?? ??? ?p1->beizhu =beiz(b); ?? ??? ??? ?break; ?? ?default : ?? ??? ?cout<<"輸入錯(cuò)誤??!"<<endl; }? cout<<"是否更改其他信息?Y OR N"<<endl; char key; cin>>key; if(key=='n'||key=='N') ?? ??? ?c=0;} ?? ??? ?cout<<"修改成功??!"<<endl; }} ? banche *del(banche *head)?? ??? ?//刪除班車記錄 { ?? ?banche *p1,*p2; ?? ?int a; ?? ?char key; ?? ?if (head=NULL) ?? ?{ ?? ?cout<<"沒有數(shù)據(jù)"<<endl; ?? ?return head; ?? ?} ?? ?p1=head; ?? ?p2=p1; ?? ?cout<<"請(qǐng)輸入班車編號(hào)"<<endl; ?? ?cin>>a; ?? ?while(a!=p1->bianhao &&p1->next !=NULL) ?? ?{ ?? ?p2=p1; ?? ?p1=p1->next; ?? ?} ?? ?if(a==p1->bianhao ) ?? ?{ ?? ??? ?cout<<"編號(hào)\t"<<"起點(diǎn)\t"<<"終點(diǎn)\t"<<"座位數(shù)\t"<<"發(fā)車時(shí)間\t"<<endl ?? ??? ??? ?<<p1->bianhao <<'\t'<<p1->qidian <<'\t'<<p1->zhongdian <<'\t' ?? ??? ??? ?<<p1->zuoweishu <<'\t'<<" 點(diǎn)"<<" 分"<<'\t'<<endl; ?? ??? ?cout<<"確定要?jiǎng)h除本條記錄嗎?Y(是),N(否)"<<endl; ?? ??? ?cin>>key; ?? ??? ?if(key=='Y'||key=='y') ?? ??? ?{ ?? ??? ??? ?if(p1==head) ?? ??? ??? ??? ?head=p1->next; ?? ??? ??? ?else ?? ??? ??? ??? ?p2->next=p1->next ; ?? ??? ??? ?cout<<"刪除成功!"<<endl; ?? ??? ??? ?n--; ?? ??? ?} ?? ?} ?? ?else ?? ??? ?cout<<a<<" 不存在的班次"<<endl; ? ?? ?return head; } void chache(banche *head)?? ?//班次信息查詢 { ?? ?int a; ?? ?banche *p,*p1; ?? ?p=head; ?? ?cout<<"請(qǐng)選擇查詢方式:"<<endl ?? ??? ?<<"1. 查看全部班次 ? ? 2.查看指定編號(hào)班次"<<endl; ?? ?cin>>a; ?? ?if(a==1) ?? ?{ ?? ??? ?cout<<"編號(hào)\t"<<"出發(fā)地\t"<<"終點(diǎn)站\t"<<"最大載客量\t"<<"剩余可載客數(shù)\t"<<"發(fā)車時(shí)間\t"<<"備注信息\t"<<endl; ?? ??? ?while(p!=NULL) ?? ?{ ?? ?cout<<p->bianhao <<p->qidian <<'\t'<<p->zhongdian <<'\t'<<p->zuoweishu ?? ??? ?<<'\t' <<p->shengyup <<'\t'<<p->fache.shi<<p->fache.fen <<'\t'<<endl; ?? ?p1=p->next ; ?? ?} ?? ?} ?? ?else if(a==2) ?? ?{ ?? ?banche cha; ?? ?cout<<"請(qǐng)輸入要查看班次的編號(hào)"<<endl; ?? ?cin>>cha.bianhao ; ?? ?while(p!=NULL&&p->bianhao!=cha.bianhao ) ?? ?{ ?? ?p1=p; ?? ?p=p->next ; ?? ?} ?? ?if(p==NULL) ?? ??? ?cout<<"該班次不存在,查看失敗??!"<<endl; ?? ?else ?? ?cout<<"編號(hào)\t"<<"出發(fā)地\t"<<"終點(diǎn)站\t"<<"最大載客量\t"<<"剩余可載客數(shù)\t"<<"發(fā)車時(shí)間\t"<<"備注信息\t"<<endl ?? ??? ?<<p->bianhao <<p->qidian <<'\t'<<p->zhongdian <<'\t'<<p->zuoweishu ?? ??? ?<<'\t' <<p->shengyup <<'\t'<<p->fache.shi<<p->fache.fen <<'\t'<<endl; ?? ?} ?? ?else ?? ??? ?cout<<"輸入錯(cuò)誤!!"<<endl; ? } dingpiaoxx *HEAD=CREAT(); dingpiaoxx *CREAT()?? ??? ?//建立初始訂票信息 { ?? ?int a,b=1; ?? ?char key; dingpiaoxx *HEAD,*p1,*p2; banche *s; HEAD =NULL; p1=new(dingpiaoxx ); p2=p1; cout<<"請(qǐng)輸入姓名、身份證號(hào)"<<endl; cin>>p1->xingming >>p1->zheng ; cout<<"請(qǐng)輸入要到達(dá)的目的地:"<<"0 廣州;1 深圳;2 東莞;3 佛山;4 揭陽;5 中山;6 茂名;7 汕頭"<<endl; cin>>a; p1->gpzd=zhongd (a); cout<<"請(qǐng)輸入所訂票數(shù)(一人最多可定3張票)"<<endl; cin>>p1->piaoshu ; s=head; while(s->zhongdian !=p1->gpzd&&s->next !=NULL ) s=s->next ; if(s==NULL) ?? ?cout<<"班次不存在,請(qǐng)從新操作"<<endl; else {s->shengyup -=p1->gpzd ; while(b) { m++; if(m==1) ?? ?HEAD =p1; else {p2->NEXT =p1; p2=p1;} p1=new(dingpiaoxx ); cout<<"請(qǐng)輸入姓名、身份證號(hào)"<<endl; cin>>p1->xingming >>p1->zheng ; cout<<"請(qǐng)輸入要到達(dá)的目的地:"<<"0 廣州;1 深圳;2 東莞;3 佛山;4 揭陽;5 中山;6 茂名;7 汕頭"<<endl; cin>>a; p1->gpzd=zhongd (a); cout<<"請(qǐng)輸入所訂票數(shù)(一人最多可定3張票)"<<endl; cin>>p1->piaoshu ; s=head; while(s->zhongdian !=p1->gpzd&&s->next !=NULL ) s=s->next ; if(s==NULL) {cout<<"班次不存在,請(qǐng)從新操作"<<endl; b=0; } else {s->shengyup -=p1->gpzd ; cout<<"是否繼續(xù),Y(是),N(否)"<<endl; cin>>key; if(key=='n'||key=='N') ?? ?b=0; } ? }} delete p1; p2->NEXT =NULL; ? return HEAD ; } ? ? dingpiaoxx *dingpiao(dingpiaoxx *HEAD)?? ?//訂票 { ?? ?int a,b=1; ?? ?banche *s; ?? ?char key; ?? ?while(b=1) ?? ?{ ?? ?dingpiaoxx *p1=new dingpiaoxx ; ?? ?cout<<"請(qǐng)輸入您的姓名及身份證號(hào)"<<endl; cin>>p1->xingming >>p1->zheng ; cout<<"請(qǐng)輸入您想要到達(dá)的目的地:"<<"0 廣州;1 深圳;2 東莞;3 佛山;4 揭陽;5 中山;6 茂名;7 汕頭"<<endl; cin>>a; p1->gpzd=zhongd (a); cout<<"請(qǐng)輸入您想要訂的票數(shù)(一人最多可定3張票)"<<endl; cin>>p1->piaoshu ; if(p1->piaoshu >3) { cout<<"操作錯(cuò)誤,訂票失敗!"<<endl; delete p1; } else? { s=head; while(s->zhongdian !=p1->gpzd&&s!=NULL ) s=s->next ; if(s==NULL) { ? delete p1; ?? ?cout<<"班次不存在,訂票失??!"<<endl <<"是否重新操作:Y(是),N(否)"<<endl; ?? ?cin>>key; ?? ?if(key=='n'||key=='N') ?? ??? ?b=0; } else {s->shengyup -=p1->gpzd ; p1->NEXT =HEAD ; HEAD =p1; cout<<"訂票成功,祝您旅途愉快!"<<endl; b=0;m++;}}} return HEAD ; } void gaip(dingpiaoxx *HEAD)?? ??? ?//用于管理員維護(hù)數(shù)據(jù) { ?? ?int a; ?? ?dingpiaoxx gai,*p; ?? ?p=HEAD ; cout<<"請(qǐng)選擇輸入需要修改的姓名或身份證號(hào):1.姓名;2身份證號(hào)"<<endl; cin>>a; if(a==1) { ?? ?cout<<"請(qǐng)輸入要修改記錄的姓名"<<endl; ?? ?cin>>gai.xingming ; ?? ?while(p->xingming !=gai.xingming &&p->NEXT !=NULL) ?? ??? ?p=p->NEXT ; ?? ?if(p->NEXT ==NULL) ?? ??? ?cout<<"沒有此人的訂票信息,請(qǐng)核對(duì)后輸入?。?<<endl; ?? ?else ?? ?xiup(p); } else if(a==2) {cout<<"請(qǐng)輸入要修改記錄的身份證號(hào)碼"<<endl; ?? ?cin>>gai.zheng ?; ?? ?while(p->zheng!=gai.zheng &&p->NEXT !=NULL) ?? ??? ?p=p->NEXT ; ?? ?if(p->NEXT ==NULL) ?? ??? ?cout<<"沒有此人的訂票信息,請(qǐng)核對(duì)后輸入!!"<<endl; ?? ?else ?? ?xiup(p); } else ?? ?cout<<"輸入錯(cuò)誤,請(qǐng)按提示輸入!"<<endl; } void xiup(dingpiaoxx *HED ) { ?? ?int a,b=1; ?? ?dingpiaoxx *p1; ?? ?banche *s=head ; ?? ?p1=HED; ?? ?while (s->next!=NULL&&s->zhongdian !=p1->gpzd ) ?? ??? ??? ?s=s->next ;?? ? ?? ??? ?cout<<"姓名\t"<<"到達(dá)站\t"<<"所購票數(shù)\t"<<"車次編號(hào)\t"<<"購票日期\t"<<"購票時(shí)間\t"<<"備注信息"<<endl ?? ??? ?<<p1->xingming<<'\t'<<p1->gpzd<<'\t'<<p1->piaoshu<<s->bianhao ?? ??? ?<<'\t'<<" 年"<<' 月'<<" 日"<<'\t'<<" 點(diǎn)"<<" 分"<<" 秒"<<'\t'<<endl ?? ??? ?<<"查詢成功?。?<<endl; ?? ??? ?while(b==1) ?? ??? ?{ ?? ??? ?cout<<"請(qǐng)輸入需要修改的信息:"<<endl ?? ??? ??? ?<<"1.姓名 ?2.到達(dá)站 ?3.所購票數(shù) ?4.購票日期 ?5.購票時(shí)間 ?6.備注信息"<<endl; ?? ??? ?cin>>a; ?? ??? ?switch (a) ?? ??? ?{ ?? ??? ?case 1:cout<<"請(qǐng)輸入姓名"<<endl; ?? ??? ??? ?cin>>p1->xingming ;break; ?? ??? ?case 2:cout<<"請(qǐng)輸入身份證號(hào)碼"<<endl; ?? ??? ??? ?cin>>p1->zheng ;break; ?? ??? ?case 3:cout<<"請(qǐng)輸入訂票數(shù)"<<endl; ?? ??? ??? ?cin>>p1->piaoshu ;break; ?? ??? ?case 4:cout<<"請(qǐng)輸入購票日期(年、月、日)"<<endl; ?? ??? ??? ?cin>>p1->riqi .year >>p1->riqi .month >>p1->riqi .day ?;break; ?? ??? ?case 5:cout<<"請(qǐng)輸入購票時(shí)間(時(shí)、分、秒)"<<endl; ?? ??? ??? ?cin>>p1->shijian .shi ?>>p1->shijian .fen >>p1->shijian .miao ;break; ?? ??? ?case 6:cout<<"請(qǐng)輸入備注信息:(0.售票中,1.可發(fā)車,2.班次取消)"<<endl; ?? ??? ??? ?int k; ?? ??? ??? ?cin>>k ; ?? ??? ??? ?s->beizhu =beiz (k); break; ?? ??? ?default : ?? ??? ??? ?cout<<"輸入錯(cuò)誤,請(qǐng)按提示輸入!"<<endl; ?? ??? ?} ?? ??? ?char key; ?? ??? ?cout<<"是否要修改其他信息?Y(是),N(否)"<<endl; ?? ??? ?cin>>key; ?? ??? ?if(key=='n'||key=='N') ?? ??? ??? ?b=0;} ?? ??? ?cout<<"修改成功?。?<<endl; } void chapiao(dingpiaoxx *HEAD )?? ??? ?//訂票信息查詢(管理員使用) { ?? ?dingpiaoxx *p1; ?? ?banche *s=head ; ?? ?p1=HEAD ; ?? ?cout<<"姓名\t"<<"到達(dá)站\t"<<"所購票數(shù)\t"<<"車次編號(hào)\t"<<"購票日期\t"<<"購票時(shí)間\t"<<"備注信息"<<endl; ?? ?while(p1->NEXT !=0) ?? ?{ ?? ?while (s->next!=NULL&&s->zhongdian !=p1->gpzd ) ?? ??? ??? ?s=s->next ; ?? ??? ??? ?s->shengyup -=p1->piaoshu ; ?? ??? ? ?? ??? ?cout<<p1->xingming<<'\t'<<p1->gpzd<<'\t'<<p1->piaoshu<<s->bianhao ?? ??? ?<<'\t'<<" 年"<<' 月'<<" 日"<<'\t'<<" 點(diǎn)"<<" 分"<<" 秒"<<'\t'<<endl; ?? ?} ?? ?cout<<"查詢成功??!"<<endl; } dingpiaoxx *tuip(dingpiaoxx *HEAD )?? ??? ?//客戶查詢和退票 { ?? ?dingpiaoxx *p1,*p2; ?? ?dingpiaoxx cx; ?? ?banche *s; ?? ?char key; ?? ?int a,b=1; ?? ?while(b==1) ?? ?{ ?? ?p1=HEAD ; ?? ?p2=p1; ?? ?cout<<"請(qǐng)輸入您的姓名和身份證號(hào)碼"<<endl; ?? ?cin>>cx.xingming >>cx.zheng ; ?? ?while(cx.xingming !=p1->xingming &&cx.zheng !=p1->zheng&&p1!=NULL ) ?? ?{ ?? ?p2=p1; ?? ?p1=p2->NEXT ; ?? ?} ?? ?if(cx.xingming==p1->xingming&&cx.zheng ==p1->zheng) ?? ??? ?{ ?? ??? ??? ?s=head; ?? ??? ??? ?while (s->next!=NULL&&s->zhongdian !=p1->gpzd ) ?? ??? ??? ?s=s->next ; ?? ??? ??? ?s->shengyup -=p1->piaoshu ; ?? ??? ? ?? ??? ??? ?cout<<"姓名\t"<<"到達(dá)站\t"<<"所購票數(shù)\t"<<"車次編號(hào)\t"<<"購票日期\t"<<"購票時(shí)間\t"<<"備注信息"<<endl ?? ??? ?<<p1->xingming<<'\t'<<p1->gpzd<<'\t'<<p1->piaoshu<<s->bianhao ?? ??? ?<<'\t'<<" 年"<<' 月'<<" 日"<<'\t'<<" 點(diǎn)"<<" 分"<<" 秒"<<'\t'<<endl ?? ??? ?<<"查詢成功??!"<<endl; ? ?? ?cout<<"請(qǐng)選擇您的操作:1.退票; ? ?2.返回"<<endl; ?? ?cin>>a; ?? ?switch (a) ?? ?{ ?? ?case 1: ?? ??? ?if(p1==HEAD ) ?? ??? ??? ?HEAD =p1->NEXT ; ?? ??? ?else ?? ??? ?p2->NEXT =p1->NEXT ; ?? ??? ?m--; ?? ??? ?cout<<"您已成功退票,感謝您的支持!"<<endl; ?? ??? ?break; ?? ?case 2: ?? ??? ?return HEAD ;break; ?? ?} ?? ?b=0; ?? ?} ?? ?else if(cx.xingming ==p1->xingming&&cx.zheng !=p1->zheng) ?? ?{cout<<"姓名與身份證號(hào)不匹配,請(qǐng)重新輸入!確定(Y) ?取消(N)"<<endl; ?? ?cin>>key; ?? ?if(key=='n'||key=='N') ?? ?b=0;} ?? ?else ?? ?{cout<<"沒有您的購票記錄或輸入信息有誤,請(qǐng)核實(shí)后輸入"<<endl; ?? ?cout<<"確定重新輸入請(qǐng)按“Y”,取消請(qǐng)按“N”"<<endl; ?? ?cin>>key; ?? ?if(key=='n'||key=='N') ?? ?b=0; ?? ?} ?? ?} ?? ?return HEAD ; } dingpiaoxx ?*tianjia(dingpiaoxx *HEAD)?? ?//管理員更改數(shù)據(jù)或人工售票 { ? ?? ?return HEAD; } dingpiaoxx *shanc(dingpiaoxx *HEAD )?? ?//人工退票、數(shù)據(jù)更新 { ?? ?dingpiaoxx *p,ss; ?? ?p=HEAD ; ?? ?cout<<"請(qǐng)輸入要?jiǎng)h除的記錄的姓名或身份證號(hào):1.姓名 ?2.身份證號(hào)碼"<<endl; ?? ?int a; ?? ?cin>>a; ?? ?if(a==1) ?? ?{ ?? ??? ?cout<<"請(qǐng)輸入刪除者姓名"<<endl; ?? ??? ?cin>>ss.xingming ; ?? ?while( p->NEXT!=NULL && p->xingming ==ss.xingming ) ?? ??? ?p=p->NEXT ; ?? ?} ?? ?return HEAD ; } void welc()?? ??? ?//歡迎界面 { cout<<"***-。-。-。-。-。-。-。-***"<<endl ?? ?<<"* ? ? ? ? ? ? ? ? ? ? ? ? ?*"<<endl ?? ?<<"| ? ? ? ? ? ? ? ? ? ? ? ? ?|"<<endl ?? ?<<"。 ? ?歡迎使用本系統(tǒng) ? ? ? 。"<<endl ?? ?<<"| ? ? ? ? ? ? ? ? ? ? ? ? ?|"<<endl ?? ?<<"* ? ? ? ? ? ? ? ? ? ? ? ? ?*"<<endl ?? ?<<"***-。-。-。-。-。-。-。-***"<<endl; ? } void xuanze()?? ?//兩個(gè)接口進(jìn)入系統(tǒng),管理員和用戶采用不同入口 ?? ??? ??? ??? ?//管理員進(jìn)入管理界面需登陸 { ?? ?cout<<"######################################"<<endl ?? ??? ?<<"### ? ? ? ? 請(qǐng)選擇入口 ? ? ? ? ? ? ###"<<endl ?? ??? ?<<"######################################"<<endl ?? ??? ?<<" "<<endl ?? ??? ?<<"&&&&&& ? 我是叼炸天的管理員 ? ?&&&&&&"<<endl ?? ??? ?<<" ? ? ? ? ? ? 代號(hào):1 ? ? ? ? ? ? ? ? "<<endl ?? ??? ?<<" "<<endl ?? ??? ?<<"&&&&&& ? ?我只是個(gè)寂寞的乘客 ? &&&&&&"<<endl ?? ??? ?<<" ? ? ? ? ? ?代號(hào):2 ? ? ? ? ? ? ? ? ?"<<endl ?? ??? ?<<" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? "<<endl; } void chushi() { ?? ?cout<<"首次使用系統(tǒng),請(qǐng)進(jìn)完善始數(shù)據(jù)"<<endl ?? ?<<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"<<endl ?? ?<<"第一項(xiàng):請(qǐng)建立班次信息表并輸入初始數(shù)據(jù)"<<endl; ?? ?banche *creat(); ?? ?cout<<"班車信息已建立!!"<<endl ?? ??? ?<<"第二項(xiàng):請(qǐng)建立訂票信息表"<<endl; ?? ?dingpiaoxx *CREAT(); ?? ?//cout<<"訂票信息表已成功建立,請(qǐng)按任意鍵進(jìn)入主界面"<<endl; } void weihu()?? ??? ?//數(shù)據(jù)維護(hù)總函數(shù),管理員使用,包括所有信息的查詢、 ?? ??? ??? ??? ??? ?//修改、增添新紀(jì)錄、刪除原有記錄 { ?? ?int a; ?? ?cout<<"歡迎進(jìn)入班車信息系統(tǒng)維護(hù)系統(tǒng)"<<endl; ?? ?cout<<"請(qǐng)選擇您要進(jìn)行的操作:"<<endl ?? ??? ?<<"1.班次信息查詢\t"<<"2.訂票信息查詢\t"<<endl ?? ??? ?<<"3.添加班次記錄\t"<<"4.刪除班次記錄\t"<<endl ?? ??? ?<<"5.添加訂票記錄\t"<<"6.刪除訂票記錄\t"<<endl ?? ??? ?<<"7.修改班次記錄\t"<<"8.修改訂票記錄\t"<<endl; ?? ?cin>>a; ?? ?switch (a) ?? ?{ ?? ?case 1: chache(head);break; ?? ?case 2: chapiao(HEAD );break; ?? ?case 3:head=charu(head );break; ?? ?case 4:head=del(head); break; ?? ?case 5:HEAD =tianjia(HEAD ); break; ?? ?case 6:HEAD=shanc (HEAD );break; ?? ?case 7:xiug(head); break; ?? ?case 8: gaip(HEAD );break; ?? ?default : ?? ??? ?cout<<"輸入錯(cuò)誤,請(qǐng)輸入正確的操作序號(hào)"<<endl; ?? ?} } void kehu() ?//用戶中心,用戶在此選擇需要的操作 { ?? ?cout<<"歡迎您,請(qǐng)選擇您要進(jìn)行的操作:"<<endl ?? ??? ?<<"1.車次信息查看 ? 2.我要購票 ? ? 3.已購票查詢及退訂 "<<endl; ?? ?int a; ?? ?cin>>a; ?? ?switch (a) ?? ?{ ?? ?case 1: chache(head);break; ?? ?case 2:HEAD=dingpiao(HEAD );break; ?? ?case 3:HEAD=tuip (HEAD);break; ?? ?default : ?? ??? ?cout<<"輸入錯(cuò)誤,請(qǐng)按提示信息輸入"<<endl; ?? ?} } int denglu()?? ?//管理員登陸函數(shù) { ?? ?guanli ff; ?? ?int n=4; ?? ?for(;n>0;) ?? ?{ ?? ??? ?n--; cout<<"請(qǐng)輸入您的賬號(hào)和密碼"<<endl; cin>>ff.zh >>ff.mima ; if((ff.zh ==guan1 .zh &&ff.mima ==guan1 .mima)||(ff.zh ==guan2 .zh &&ff.mima ==guan2 .mima) ) {cout<<"恭喜:登陸成功??!"<<endl; ?? ?return 1;break;} else? cout<<"賬號(hào)或密碼錯(cuò)誤,請(qǐng)重新輸入" <<"還有"<<n<<"次機(jī)會(huì)"<<endl; ?? ?} ?? ?cout<<"登陸失?。。。?<<endl; return 2;}
建立鏈表:
歡迎界面
管理員主頁面
乘客查詢
對(duì)于時(shí)間和日期的問題,上網(wǎng)查了很多,各種方式,但都是直接輸出的形式,未能找到一個(gè)能成功地將時(shí)間、日期的各個(gè)部分提取出來放入數(shù)組或變量中的方法(主要是停網(wǎng)之后上網(wǎng)極不方便,時(shí)間上受極大限制),所以,很多地方都跳過了對(duì)時(shí)間和日期的操作。
通過這次作業(yè)深刻體會(huì)到作為“程序猿”的痛苦,我知道我的程序有很多地方不夠完善,有很多漏洞,與老師的要求還有一定出入,但我確實(shí)努力地做了,由于時(shí)間問題,不完善的地方只有以后慢慢修改了。
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
VSCode遠(yuǎn)程開發(fā)調(diào)試服務(wù)器c/c++代碼
語音相關(guān)的好多項(xiàng)目要在linux上跑,但代碼開發(fā)大多是在PC機(jī)上,本篇簡單介紹一下怎么在個(gè)人電腦上用VSCode遠(yuǎn)程開發(fā)調(diào)試服務(wù)器上的c/c++代碼。感興趣的朋友跟隨小編一起看看吧2020-04-04C++實(shí)現(xiàn)簡單職工管理系統(tǒng)
這篇文章主要為大家詳細(xì)介紹了C++職工管理系統(tǒng)實(shí)訓(xùn)代碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-04-04C++ 內(nèi)存分配處理函數(shù)set_new_handler的使用
這篇文章主要介紹了C++ 內(nèi)存分配處理函數(shù)set_new_handler的使用,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-02-02C++實(shí)現(xiàn)LeetCode(154.尋找旋轉(zhuǎn)有序數(shù)組的最小值之二)
這篇文章主要介紹了C++實(shí)現(xiàn)LeetCode(154.尋找旋轉(zhuǎn)有序數(shù)組的最小值之二),本篇文章通過簡要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-07-07