Advertisement
Guest User

Untitled

a guest
Jul 25th, 2012
815
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1.  
  2. #include<iostream>
  3. #include<cstdio>
  4. #include<cstdlib>
  5. #include<cassert>
  6. #include<cmath>
  7. #include<ctime>
  8. #include<cstring>
  9. #include<cctype>
  10. #include<algorithm>
  11. #include<string>
  12. #include<vector>
  13. #include<iomanip>
  14. using namespace std;
  15. vector < vector<int> > g; // граф
  16. int n; // число вершин
  17.  
  18. vector<bool> used;
  19.  
  20. void dfs (int v) {
  21. used[v] = true;
  22. cout<<v;
  23. for (vector<int>::iterator i=g[v].begin(); i!=g[v].end(); ++i)
  24. if (!used[*i])
  25. dfs (*i);
  26. }
  27. int main(){
  28. n=4;
  29. int i;
  30. for(i=1;i<=n;++i){
  31. dfs(i);
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement