?? 最終修改.txt
字號:
cin>>fun;
switch(fun)
{
case 0:
break;
case 1:
cout<<" 請輸入公交的路線"<<endl;
cin>>input_line;
for(boy0=0;boy0<=bus_num;boy0++)
{
line_cmp_result=strcmp(input_line,bus_line[boy0].name);
if(line_cmp_result==0)
{
for(boy1=0;boy1<=bus_line[boy0].geshu;boy1++)
{
if(boy1%5==0)cout<<endl;
cout<<bus_line[boy0].line[boy1]<<" ";
}
correct0=1;////
}
}
if(correct0==0)
{cout<<"輸入的站點有誤"<<endl;
break;
}
cout<<endl;
break;
case 2:
cout<<" 請輸入要查詢的站點"<<endl;
cin>>input_stage;
for(girl0=0;girl0<=stage_num;girl0++)
{
compare=strcmp(input_stage,stage[girl0].name);
if(compare==0)
{
cout<<"經過的公交線為為"<<endl;
for(girl1=0;girl1<stage[girl0].line_in;girl1++)
{
if(girl1%5==0)cout<<endl;
cout<<stage[girl0].biaoji[girl1].way<<"路 ";
}
correct1=1;
}
}
if(correct1==0)
{
xiao0_counter=0;
cout<<"輸入有錯誤"<<endl;
for(she=0;she<=stage_num;she++)
{
stage[she].quan=mohu(input_stage,stage[she].name);
if(stage[she].quan>=xiao1)
{
xiao1=stage[she].quan;/////找出整個的最大權值
}
}
for(she=0;she<=stage_num;she++)
{
if(stage[she].quan==xiao1)
{
xiao0[xiao0_counter]=stage[she].num;
xiao0_counter++;
}
}
for(she=0;she<xiao0_counter;she++)
cout<<"你是不是在找 "<<stage[xiao0[she]].name<<"?"<<endl;
break;
}
cout<<endl;
break;
case 3:
int i_beg;
int i_end;
int i_beg_enable=1;
int i_end_enable=1;
cout<<"請輸入起始站點的名字"<<endl;
cin>>input1;
cout<<"請輸入終點的站名"<<endl;
cin>>input2;
for(int i=0;i<=stage_num;i++)
{
i_beg=strcmp(input1,stage[i].name);
i_end=strcmp(input2,stage[i].name);
if(i_beg==0)///////起始站找到了相同的點
{
begin_stage=stage[i].num;
i_beg_enable=0;
}
if(i_end==0)
{
end_stage=stage[i].num;
i_end_enable=0;
}
}
if(i_beg_enable==1||i_end_enable==1)
{
cout<<"輸入的站點有錯誤"<<endl;
if(i_beg_enable==1)
{
xiao0_counter=0;
cout<<"輸入起始站有錯誤"<<endl;
for(she=0;she<=stage_num;she++)
{
stage[she].quan=mohu(input1,stage[she].name);
if(stage[she].quan>=xiao1)
{
xiao1=stage[she].quan;/////找出整個的最大權值
}
}
for(she=0;she<=stage_num;she++)
{
if(stage[she].quan==xiao1)
{
xiao0[xiao0_counter]=stage[she].num;
xiao0_counter++;
}
}
for(she=0;she<xiao0_counter;she++)
cout<<"你是不是在找 "<<stage[xiao0[she]].name<<"?"<<endl;
cout<<endl;
}
if(i_end_enable==1)
{
xiao0_counter=0;
cout<<"輸入終點站有錯誤"<<endl;
for(she=0;she<=stage_num;she++)
{
stage[she].quan=mohu(input2,stage[she].name);
if(stage[she].quan>=xiao1)
{
xiao1=stage[she].quan;/////找出整個的最大權值
}
}
for(she=0;she<=stage_num;she++)
{
if(stage[she].quan==xiao1)
{
xiao0[xiao0_counter]=stage[she].num;
xiao0_counter++;
}
}
for(she=0;she<xiao0_counter;she++)
cout<<"你是不是在找 "<<stage[xiao0[she]].name<<"?"<<endl;
cout<<endl;
}
goto labnext;
}
///////////****到此已經得到了起點和終點在整個stage數組中的位置****////////////
///////////下面就是對起點和終點所包括的集合里取交集//////////
for(int qq0=0;qq0<stage[begin_stage].line_in;qq0++)
for(int qq1=0;qq1<stage[end_stage].line_in;qq1++)
{
int tmp_ji;
tmp_ji=strcmp(stage[begin_stage].biaoji[qq0].way,stage[end_stage].biaoji[qq1].way);
if(tmp_ji==0)
{
strcpy(same[same_counter0],stage[begin_stage].biaoji[qq0].way);
same_counter0++;
}
}
for(int an=0;an<same_counter0;an++)
{
if(an==0)
{
cout<<"有直達車"<<endl;
cout<<endl;
}
cout<<"第"<<an+1<<"條為"<<same[an]<<"路"<<endl;
}
/////////***不轉車的情況結束,驗證成功***//////////
////////****以下是要轉一次車的情況*****///////
if(same_counter0==0)
{
for(int pp0=0;pp0<stage[begin_stage].line_in;pp0++)////////遍歷所有經過這個站點的路線
{
for(int pp1=0;pp1<=bus_num;pp1++)
{
int tmp_use;
tmp_use=strcmp(stage[begin_stage].biaoji[pp0].way,bus_line[pp1].name);
if(tmp_use==0)////尋找公交車號相同的,將經過的站臺的存放到line_all
{
for(int pp2=0;pp2<=bus_line[pp1].geshu;pp2++)
{
int tmp10;
for(int pp3=0;pp3<=cross_stage;pp3++)///////查詢是不是有重復的站點的進入,防止重復
{
tmp10=strcmp(bus_line[pp1].line[pp2],line_all[pp3]);
if(tmp10==0)
{
enable_add=0;
break;
}
}
if(enable_add==1)
{
strcpy(line_all[cross_stage],bus_line[pp1].line[pp2]);
cross_stage++;
}
enable_add=1;
}
}
}
}
///////////////*****到此為止已經得到了由起始站點所能達到的站點的值,放在line_all數組里,站的數目為cross_stage**/////////
/////////以下是將line_all數組里的站點所經過的路線全部保存到一個數組里//////////
for(int jj0=0;jj0<cross_stage;jj0++)
for(int jj1=0;jj1<=stage_num;jj1++)
{
int we;
we=strcmp(line_all[jj0],stage[jj1].name);
if(we==0)///相同的站點則將此站點所經過的路線值導入
{
for(int jj2=0;jj2<stage[jj1].line_in;jj2++)
{
for(int jj3=0;jj3<=line_num_flag;jj3++)/////查詢現有的line_num數組里是不是已經有相同的值
{
int tmp_ji1;
tmp_ji1=strcmp(stage[jj1].biaoji[jj2].way,line_num[jj3]);
if(tmp_ji1==0)
{
line_num_enable=0;
break;
}
}
if(line_num_enable==1)/////允許計入到數組
{
strcpy(line_num[line_num_flag],stage[jj1].biaoji[jj2].way);
line_num_flag++;
}
line_num_enable=1;
}
}
}
for(int jj5=0;jj5<line_num_flag;jj5++)//////取相同的值
for(int jj6=0;jj6<stage[end_stage].line_in;jj6++)
{
int tmp_ji2;
tmp_ji2=strcmp(line_num[jj5],stage[end_stage].biaoji[jj6].way);
if(tmp_ji2==0)
{
strcpy(same1_2[same1_2counter],line_num[jj5]);
same1_2counter++;
}
}
////////**起點的中轉與終點的交集結束**///////
////***起點的中轉與起點的交集得到從起點到終點所坐的車***/////
for(int jj9=0;jj9<line_num_flag;jj9++)
for(int jj10=0;jj10<stage[begin_stage].line_in;jj10++)
{
int tmp_ji3;
tmp_ji3=strcmp(line_num[jj9],stage[begin_stage].biaoji[jj10].way);
if(tmp_ji3==0)
{
strcpy(same1_1[same1_1counter],line_num[jj9]);
same1_1counter++;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -