Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdio>
- #include<cstdlib>
- #include<cassert>
- #include<cmath>
- #include<ctime>
- #include<cstring>
- #include<cctype>
- #include<algorithm>
- #include<string>
- #include<vector>
- #include<iomanip>
- using namespace std;
- vector < vector<int> > g; // граф
- int n; // число вершин
- vector<bool> used;
- void dfs (int v) {
- used[v] = true;
- cout<<v;
- for (vector<int>::iterator i=g[v].begin(); i!=g[v].end(); ++i)
- if (!used[*i])
- dfs (*i);
- }
- int main(){
- n=4;
- int i;
- for(i=1;i<=n;++i){
- dfs(i);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement