学无先后,达者为师

网站首页 编程语言 正文

C++基于Floyd算法实现校园导航系统_C 语言

作者:很小小的   更新时间: 2022-05-24 编程语言

本文实例为大家分享了C++基于Floyd算法实现校园导航系统的具体代码,供大家参考,具体内容如下

首先是配置文件

//文件名'MGraph.h'
//用途:创建邻接矩阵
#include
#include
using namespace std;
/*
*author:xcy 
*date:2019.6.1 
*/
#define MaxInt 32767 //表示极大值
#define MaxNum 100  //表示最大顶点数
typedef int status;
typedef string VerTexType;  //顶点的数据类型
typedef int ArcType;  //边的权值为整型
typedef struct
{
    VerTexType vexs[MaxNum];   //顶点表
    ArcType arcs[MaxNum][MaxNum];   //邻接矩阵
    int vexnum,arcnum;//当前的点和边数
    char name[MaxNum];
}AMGraph;

status CreateMap(AMGraph &G)//地图的创建 
{
    G.vexnum=10; 
    G.arcnum=13;
    G.vexs[0]="北门";
    G.vexs[1]="下沉广场";
    G.vexs[2]="青年公寓";
    G.vexs[3]="齐贤广场";
    G.vexs[4]="15教";
    G.vexs[5]="菜鸟驿站";
    G.vexs[6]="汇森楼";
    G.vexs[7]="图书馆";
    G.vexs[8]="体育馆";
    G.vexs[9]="南苑餐厅";
    
    for(int i=0;i

具体方法实现

#include
#include
#include"MGraph.h" 
using namespace std;
/*
*author:xcy 
*date:2019.6.12
*change:使用弗洛依德算法 
*/

int shortPath[MaxNum][MaxNum];//最短路径长度 
int Path[MaxNum][MaxNum];//保存下一个节点 
void ShortestPath_Floyd(AMGraph G)//弗洛依德算法
{
    int i,j,k;
    for(i=0;i>a;
    cout<<"输入终点的序号"<>b;
    m=a-1;
    n=b-1;
    cout<<"最短路径:"< "< "<>a;
        (int)a;
        if(a>'0'&&a<='3')
            switch(a)
            {
                  case '1': scence(); break;
                  case '2': math(); break;
                  case '3': cout<<"\t\t\t感谢您的使用!";exit(0);break;
              }
          else cout<<"\t\t\t请输入1-3!!"<

原文链接:https://blog.csdn.net/weixin_44371591/article/details/92001056

栏目分类
最近更新