题解 1703: 数据结构-图的遍历-BFS广度优先搜索(广搜)

来看看其他人写的题解吧!要先自己动手做才会有提高哦! 
返回题目 | 我来写题解

筛选

广度优先搜索BFS(cx14a)

解题思路:从0开始遍历,即从第1行还是查找a[0][i]=1&&visited==0//按行查找矩阵为1,且为没有被遍历的元素//例如第一行的a[0][3]==1&&visited[3]==0//则下方将其入队,并标记为1,出队并输出//继续while循环,

1703:BFS广搜

解题思路:注意事项:参考代码:#includeusingnamespacestd;inta[51][51];intvisited[51];intn;voidbfs(intv){queueq;visited[v]=1;q.push(v);while(!q.empt

BFS广度优先搜索

摘要:解题思路:看注释注意事项:参考代码:#include<bits/stdc++.h>using namespace std;const int N=55;int mp[N][N];//邻接矩阵 int ……