Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <list>
  3. #include <stack>
  4.  
  5. using namespace std;
  6. void DFS(int v)
  7. {
  8. int u;
  9. bool visited[10];
  10. stack<int> stos;
  11. list<int> lista;
  12. stos.push(v);
  13. visited[v] = true;
  14.  
  15. while (!stos.empty())
  16. {
  17. u = stos.top();
  18. for (int i = 0; i < lista.size(u); i++)
  19. {
  20. if (visited[i]==false)
  21. {
  22. stos.push(i);
  23. visited[i] = true;
  24. }
  25. else
  26. stos.pop();
  27. }
  28. }
  29. }
  30. int main()
  31. {
  32. int v;
  33. cin >> v;
  34. DFS(v);
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement