整理一下,背过吧,为了AC。

邻接矩阵:

DFS:

void dfs(int p)
{
    cout<<p<<" ";
    vis[p]=true;
    for(int i=1; i<=m; i++)
        if(!vis[i])
            dfs(i);
}
View Code

相关文章:

  • 2022-12-23
  • 2021-09-30
  • 2021-07-31
  • 2022-01-08
  • 2021-05-20
  • 2021-10-25
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-30
  • 2021-08-10
  • 2021-11-26
  • 2022-12-23
相关资源
相似解决方案