Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <list>
- #include <stack>
- using namespace std;
- void DFS(int v)
- {
- int u;
- bool visited[10];
- stack<int> stos;
- list<int> lista;
- stos.push(v);
- visited[v] = true;
- while (!stos.empty())
- {
- u = stos.top();
- for (int i = 0; i < lista.size(u); i++)
- {
- if (visited[i]==false)
- {
- stos.push(i);
- visited[i] = true;
- }
- else
- stos.pop();
- }
- }
- }
- int main()
- {
- int v;
- cin >> v;
- DFS(v);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement