#define INFINITY 10000 /*图的矩阵中A(i,i)记为0,若没有通路,记为infinity = 10000。*/
#define MAX_VERTEX_NUM 40 //最大定点数定为40
#define MAX 40
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>
typedef struct ArCell
{
int adj; //路径长度
}ArCell,AdjMatrix[MAX_VERTEX_NUM][MAX_VERTEX_NUM];
typedef struct //图中顶点表示主要景点,存放景点的编号、名称、简介等信息,
{
char name[30];
int num;
char introduction[100];//简介
}infotype;
typedef struct
{
infotype vexs[MAX_VERTEX_NUM];
AdjMatrix arcs;
int vexnum,arcnum;
}MGraph;
MGraph b;
void cmd(void);
MGraph InitGraph(void);//对图初始化
void Menu(void);//创建菜单选项
void Browser(MGraph *G);//浏览图的信息
void ShortestPath_DIJ(MGraph * G);//用Dijkstra计算两个景点的最短路径
void Floyd(MGraph *G);//用佛洛依德算法计算从任意景点出发到其他所有顶点的最短路径
void Search(MGraph *G);//查看某个景点的信息
int LocateVex(MGraph *G,char* v);//
MGraph * CreatUDN(MGraph *G);//手动创建一个校园图,为相应的边赋值
void print(MGraph *G);
/******************************************************/
void main(void)
{
system("color 1f");
system("mode con: cols=140 lines=130");
cmd();
}
/******************************************************/
void cmd(void)
{
int i;
b=InitGraph();
Menu();
scanf("%d",&i);
while(i!=5)
{
switch(i)
{
case 1:system("cls");Browser(&b);Menu();break;
case 2:system("cls");ShortestPath_DIJ(&b);Menu();break;
case 3:system("cls");Floyd(&b);Menu();break;
case 4:system("cls");Search(&b);Menu();break;
case 5:exit(1);break;
default:break;
}
scanf("%d",&i);
}
}
MGraph InitGraph(void)
{
MGraph G;
int i,j;
G.vexnum=10;
G.arcnum=14;
for(i=0;i<G.vexnum;i++)
G.vexs[i].num=i;
strcpy(G.vexs[0].name,"第一餐厅");
strcpy(G.vexs[0].introduction,"传统标准化食堂,价格实惠");
strcpy(G.vexs[1].name,"八景园");
strcpy(G.vexs[1].introduction,"鸟语花香,绿树成荫,适宜休息和读书");
strcpy(G.vexs[2].name,"2号学生宿舍楼");
strcpy(G.vexs[2].introduction,"计算机系男生宿舍楼,历史悠久");
strcpy(G.vexs[3].name,"青春广场");
strcpy(G.vexs[3].introduction,"举办户外的大型歌舞晚会");
strcpy(G.vexs[4].name,"钟楼");
strcpy(G.vexs[4].introduction,"烟大标志性建筑,计算机学院领导办公楼");
strcpy(G.vexs[5].name,"体育场");
strcpy(G.vexs[5].introduction,"现代化塑胶跑道,适宜锻炼身体的场所");
strcpy(G.vexs[6].name,"湖心岛");
数据结构实训 烟台大学导游系统
最新推荐文章于 2022-04-30 22:14:57 发布