exam8-2.cpp

来自「包含各种测试,查找和算法等代码,如冒泡算法,树的遍历,链表,队列,堆栈等」· C++ 代码 · 共 32 行

CPP
32
字号
#include <iostream.h>
#include <stdlib.h>

typedef char VerT;						//定义邻接矩阵图类中的VerT
typedef char DataType;					//定义顺序表类中的DataType
const int MaxVertices = 100;			//定义最大顶点个数
const int MaxQueueSize = 100;			//定义队列的最大个数
const int MaxWeight = 10000;			//定义权值的无穷大

#include "AdjMWGraph.h"					//包含邻接矩阵的图类
#include "CreatAdjMWGraph.h"			//包含邻接矩阵图的创建函数

void Printchar(char item)
{
	cout << item<<" ";
}

void main(void)
{
	AdjMWGraph g;
	char a[] = {'A','B','C','D','E'};
	RowColWeight rcw[] = {{0,1,10},{0,4,20},{1,3,30},{2,1,40},{3,2,50}};
	int n = 5, e = 5;

	CreatGraph(g, a, n, rcw, e);

	cout << "深度优先搜索序列为:";
	g.DepthFirstSearch(Printchar);
	cout << endl << "广度优先搜索序列为:";
	g.BroadFirstSearch(Printchar);
}

⌨️ 快捷键说明

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