?? 查詢航線.cpp
字號:
//查詢航線,查詢全部航線和查詢單條航線分別用兩個函數去處理
#include"FlightInfo.h"
//列舉全部航線
void ShowAllFlight(FlightNode *F)
{
cout<<"+++++++++++++++++++++++++++++++++++++++++++++"<<endl;
cout<<"本公司尚處于起步階段,暫時只開放以下航線: "<<endl;
cout<<"---------------------------------------------"<<endl;
cout<<"航班號"<<"\t"<<"終點站"<<"\t"<<"飛行日"<<endl;
for(int i=1;i<20;i++)
{
cout<<F[i].Flight <<"\t"<<F[i].Terminus <<"\t"<<F[i].Day <<endl;
}
cout<<"---------------------------------------------"<<endl;
cout<<"你可以進行以下操作:1.查看單條航線;\n"
<<"2.返回上一級.\n"
<<"請選擇:";
int chioce;
top2: cin>>chioce;
if(chioce==1)
{
ShowOneFlight(F);
}
else if(chioce==2)
{
return;
}
else
{
cout<<"輸入錯誤!請重新選擇:";
goto top2;
}
}
//查詢單條航線
void ShowOneFlight(FlightNode *F) //查詢航班的函數
{
char T[20];
int choice;
cout<<"請輸入終點站名稱:\n";
cin>>T;
FlightNode temp[20];
int n=0;
for(int i=0;i<=20;i++)
{
if(strcmp(T,F[i].Terminus)==0)
{temp[n]=F[i];n++;}
}
if(n==0)cout<<"無此終點站"<<endl;
else
{
FlightNode temp1=temp[0]; //記錄最近的航班
cout<<"航班號:"<<temp[0].Flight<<ends<<"飛機號:"<<temp[0].Plane<<ends<<"飛行日:"<<temp[0].Day<<ends<<"余票額:"<<temp[0].Left<<endl;
for(int j=1;j<n;j++)
{
if(temp[j].Day!=0)
{
cout<<"航班號:"<<temp[j].Flight<<ends<<"飛機號:"<<temp[j].Plane<<ends<<"飛行日:"<<temp[j].Day<<ends<<"余票額:"<<temp[j].Left<<endl;
if((temp[j].Day>=3)&&(temp[j-1].Day>temp[j].Day))temp1=temp[j];
}
}
cout<<"最近一天的航班:\n"
<<"航班號:"<<temp1.Flight<<ends<<"飛機號:"<<temp1.Plane<<ends<<"飛行日:"<<temp1.Day<<ends<<"余票額:"<<temp1.Left<<endl;
}
cout<<"請選擇所要的操作:1,繼續查詢 2.返回上一級\n";
top3: cin>>choice;
if(choice==1)
{
ShowOneFlight(F);
}
else if(choice==2)
{
return;
}
else
{
cout<<"輸入錯誤!請重新選擇:";
goto top3;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -