摘要: #include<iostream> #include<string> #include<cstring> #include<cmath> #include<algorithm>//非递归 using namespace std; int a[1000]; int q = 0; int flag = 阅读全文
posted @ 2019-11-23 23:35 Tomorrow1126 阅读(368) 评论(0) 推荐(0) 编辑
摘要: 关键:利用栈来保存已经搜索到的顶点,利用top来返回上一个顶点。 描述 一个连通图采用邻接表作为存储结构。设计一个算法,实现从顶点v出发的深度优先遍历的非递归过程。 输入 多组数据,每组m+2数据行。第一行有两个数字n和m,代表有n个顶点和m条边。顶点编号为1到n。第二行到第m+1行每行有两个整数h 阅读全文
posted @ 2019-11-23 15:10 Tomorrow1126 阅读(2420) 评论(0) 推荐(0) 编辑