亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

C++實(shí)現(xiàn)停車(chē)場(chǎng)管理系統(tǒng)

 更新時(shí)間:2020年04月08日 10:02:27   作者:Akatsuki__Itachi  
這篇文章主要為大家詳細(xì)介紹了C++實(shí)現(xiàn)停車(chē)場(chǎng)管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了C++實(shí)現(xiàn)停車(chē)場(chǎng)管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<stack>
#include<map>
using namespace std;
struct node
{
 string no;//車(chē)牌號(hào)
 int time;//車(chē)輛進(jìn)入的時(shí)間(以小時(shí)為單位)
 int sub;//車(chē)輛在停車(chē)場(chǎng)的位置
} nod;
map<string,int>mp;//用來(lái)檢測(cè)車(chē)輛在停車(chē)場(chǎng)或者在便道內(nèi)
deque<node>q1;//模擬停車(chē)場(chǎng)
deque<node>q2;//模擬便道
stack<node>sk;//交換媒介
string str1="park",str2="pavement";
void Push(int n)//車(chē)輛駛?cè)氩僮?
{
 cout<<"請(qǐng)輸入要進(jìn)入車(chē)輛的車(chē)牌號(hào)"<<endl;
 string x;
 int y,ans;
 cin>>x;
 cout<<"請(qǐng)輸入該車(chē)輛進(jìn)入停車(chē)場(chǎng)的時(shí)間(時(shí)間為整形時(shí)刻)"<<endl;
 cin>>y;
 if(!mp[x])//如果此車(chē)不在停車(chē)場(chǎng)或者便道內(nèi)執(zhí)行以下命令
 {
 if(q1.size()<n)//如果停車(chē)場(chǎng)未滿
 {
 nod.no=x;
 nod.time=y;
 nod.sub=q1.size()+1;
 q1.push_back(nod);
 mp[x]=q1.size();
 }
 else//停車(chē)場(chǎng)滿了之后進(jìn)入便道
 {
 nod.no=x;
 nod.time=y;
 nod.sub=q2.size()+1;
 q2.push_back(nod);
 mp[x]=n+q2.size();
 }
 }
 else
 cout<<"錯(cuò)誤:該車(chē)輛已在停車(chē)場(chǎng)內(nèi)!"<<endl;
}
void Pop(int n)//車(chē)輛駛出操作
{
 cout<<"請(qǐng)輸入要駛出車(chē)輛的車(chē)牌號(hào)"<<endl;
 string x;
 int y,ans;
 cin>>x;
 cout<<"請(qǐng)輸入該車(chē)輛駛出停車(chē)場(chǎng)的時(shí)間(時(shí)間為整形時(shí)刻)"<<endl;
 cin>>y;
 if(!mp[x])
 cout<<"錯(cuò)誤:該輛并不在停車(chē)場(chǎng)內(nèi)!"<<endl;
 else if(mp[x]<=n)//如果該車(chē)在停車(chē)場(chǎng)內(nèi)
 {
 mp[x]=0;
 while(q1.back().no!=x)//車(chē)出
 {
 q1.back().sub--;
 sk.push(q1.back());
 q1.pop_back();
 }
 ans=y-q1.back().time;
 q1.pop_back();
 while(!sk.empty())
 {
 q1.push_back(sk.top());
 sk.pop();
 mp[q1.back().no]=q1.back().sub;
 }
 if(!q2.empty())//如果便道里也有車(chē),那么進(jìn)入停車(chē)場(chǎng),并且便道后面的車(chē)向前移動(dòng)
 {
 q2.front().time=y;
 q2.front().sub=q1.size()+1;
 q1.push_back(q2.front());
 q2.pop_front();
 while(!q2.empty())
 {
 q2.back().sub--;
 sk.push(q2.back());
 q2.pop_back();
 }
 while(!sk.empty())
 {
 q2.push_back(sk.top());
 sk.pop();
 mp[q2.back().no]=q1.back().sub;
 }
 mp[q1.back().no]=q1.size();
 }
 cout<<"該車(chē)輛一共停了 "<<ans<<" 個(gè)小時(shí)"<<endl;
 cout<<"所以該車(chē)輛需要繳納 "<<ans*5<<"元"<<endl;
 }
 else if(mp[x]>n)//如果車(chē)在便道里,那么直接離開(kāi),后面的車(chē)向前移動(dòng)
 {
 mp[x]=0;
 while(q2.back().no!=x)
 {
 q2.back().sub--;
 sk.push(q2.back());
 q2.pop_back();
 }
 q2.pop_back();
 while(!sk.empty())
 {
 q2.push_back(sk.top());
 sk.pop();
 }
 cout<<"由于該車(chē)輛并未進(jìn)入停車(chē)場(chǎng),所以不進(jìn)行收費(fèi)"<<endl;
 }
}
void Query1(int n)//查詢(xún)停車(chē)場(chǎng)的停車(chē)狀態(tài)
{
 cout<<"請(qǐng)輸入要查詢(xún)狀態(tài)的車(chē)牌號(hào)"<<endl;
 cout<<endl;
 string x;
 cin>>x;
 if(!mp[x])
 cout<<"該車(chē)輛并未在停車(chē)場(chǎng)"<<endl;
 else if(mp[x]<=n)
 cout<<"該車(chē)輛位于停車(chē)場(chǎng)"<<mp[x]<<"號(hào)位"<<endl;
 else
 cout<<"該車(chē)輛位于"<<mp[x]-n<<"號(hào)便道"<<endl;
}
void Query2(int n)//查詢(xún)停車(chē)場(chǎng)的空車(chē)位
{
 cout<<endl;
 if(q1.size()==n)
 cout<<"停車(chē)場(chǎng)已滿"<<endl;
 else
 {
 cout<<"停車(chē)場(chǎng)的"<<q1.size()+1;
 for(int i=q1.size()+2; i<=n; i++)
 cout<<"、"<<i;
 cout<<"號(hào)位車(chē)為空"<<endl;
 }
}
int main()
{
 int n;
 cout<<" **************停車(chē)場(chǎng)管理系統(tǒng)**************"<<endl;
 cout<<endl;
 cout<<"停車(chē)場(chǎng)管理系統(tǒng)說(shuō)明:"<<endl;
 cout<<"1.當(dāng)停車(chē)場(chǎng)車(chē)位已滿之后,車(chē)將會(huì)停在便道"<<endl;
 cout<<"2.停車(chē)場(chǎng)按照每小時(shí)五元的標(biāo)準(zhǔn)收費(fèi)(不足一小時(shí)按照一小時(shí)計(jì)算)"<<endl;
 cout<<"3.停在便道的車(chē)輛不收費(fèi)。"<<endl;
 cout<<endl;
 cout<<"首先請(qǐng)?jiān)O(shè)置停車(chē)場(chǎng)的總共的車(chē)位數(shù):"<<endl;
 cin>>n;
 cout<<endl;
 cout<<"*********車(chē)位設(shè)置完畢!下面開(kāi)始停車(chē)場(chǎng)管理系統(tǒng)模擬*********"<<endl;
 cout<<endl;
 cout<<" *********操作說(shuō)明*********"<<endl;
 cout<<endl;
 cout<<"車(chē)輛駛?cè)氲怯?>請(qǐng)按1 ^_^ 車(chē)輛駛出登記->請(qǐng)按2 ^_^"<<endl;
 cout<<endl;
 cout<<"查詢(xún)停車(chē)場(chǎng)的停車(chē)狀態(tài)->請(qǐng)按3 ^_^ 查詢(xún)停車(chē)場(chǎng)空閑車(chē)位->請(qǐng)按4 ^_^ "<<endl;
 cout<<endl;
 cout<<"退出停車(chē)場(chǎng)管理系統(tǒng)->請(qǐng)按0 ^_^"<<endl;
 cout<<endl;
 cout<<"說(shuō)明完畢!下面開(kāi)始操作"<<endl;
 cout<<endl;
 while(1)
 {
 cout<<"********請(qǐng)選擇操作1~4或者退出按0********"<<endl;
 cout<<endl;
 int t;
 cin>>t;
 if(t==1)
 Push(n);
 else if(t==2)
 Pop(n);
 else if(t==3)
 Query1(n);
 else if(t==4)
 Query2(n);
 else
 break;
 cout<<endl;
 cout<<"***********************biubiu***********************"<<endl;
 cout<<"***********************biubiu***********************"<<endl;
 cout<<endl;
 }
 cout<<"歡迎使用停車(chē)場(chǎng)管理系統(tǒng),期待您的下次使用^_^"<<endl;
}

結(jié)果:

推薦幾篇文章:

C++實(shí)現(xiàn)簡(jiǎn)單的圖書(shū)管理系統(tǒng)

C++實(shí)現(xiàn)簡(jiǎn)單的職工信息管理系統(tǒng)

C++基礎(chǔ)學(xué)生管理系統(tǒng)

關(guān)于管理系統(tǒng)的更多內(nèi)容請(qǐng)點(diǎn)擊《管理系統(tǒng)專(zhuān)題》進(jìn)行學(xué)習(xí)

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論