cpp1.cpp

来自「是一种数据结构的编程代码」· C++ 代码 · 共 34 行

CPP
34
字号
#include "iostream.h"
#include "Graph.h"
main()
{
 char a[10];
 long pathlength;
 int st=0,nd=0;
 Path p[25];
 MGraph mGraph;
 cout<<"        ***************你必须打入该城市的汉语拼音运行*********************"<<endl;
 cout<<endl;
 cout<<"               input the begin city:";
 
 cin>>a;
 st=mGraph.SearchVex(a);
 cout<<endl;
 cout<<"               input the ultimate city:";
 cin>>a;
 nd=mGraph.SearchVex(a);
 if(st==25||nd==25){cout<<"\n               input error";return 1;}
 if(st!=nd)
 {mGraph.ShortestPath(st,nd,pathlength,p);
 cout<<endl;
 cout<<"               the best path:";
 for(int i=0;i<p[nd].num;i++)
   mGraph.PrintVex(p[nd].VPath[i]);
 cout<<endl;
 cout<<"               距离为:"<<pathlength<<"公里";
 }
 else 
cout<<"                在同一城市来往,距离为零。";

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?