数据结构实训 烟台大学导游系统

#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,"湖心岛");
  • 6
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值