AlenAntonelli

Trie propio

Jun 2nd, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <utility>
  4.  
  5. using namespace std;
  6.  
  7. struct macumba {
  8.     vector< pair<int, macumba> > v;
  9. }mak;
  10.  
  11. void recorrer (macumba &padre, int n)
  12. {
  13.     cout<<padre.v[0].first<<endl;
  14.     macumba hijo = padre.v[0].second;
  15.     if (n-1>0)
  16.         recorrer(hijo,n-1);
  17. }
  18.  
  19. int main()
  20. {
  21.     mak.v.resize(1);
  22.     mak.v[0].second.v.resize(1);
  23.     mak.v[0].second.v[0].second.v.resize(1);
  24.     mak.v[0].second.v[0].second.v[0].second.v.resize(1);
  25.    
  26.     mak.v[0].first=3;
  27.     mak.v[0].second.v[0].first=2;
  28.     mak.v[0].second.v[0].second.v[0].first=1;
  29.    
  30.     recorrer(mak,3);
  31.    
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment