Guest User

Untitled

a guest
Jul 17th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. int Trie::CountPart(){
  2. int counter = 0;
  3.  
  4. for(int j = 0; j < TrieMaxElem; j++){
  5. if(j == 0){
  6. counter = counter + CountPart(root -> GetPtr(j), 1, 0, 0, 0, 0);
  7. }else if(j == 4){
  8. counter = counter + CountPart(root -> GetPtr(j), 0, 1, 0, 0, 0);
  9. }else if(j == 8){
  10. counter = counter + CountPart(root -> GetPtr(j), 0, 0, 1, 0, 0);
  11. }else if(j == 14){
  12. counter = counter + CountPart(root -> GetPtr(j), 0, 0, 0, 1, 0);
  13. }else if(j == 20){
  14. counter = counter + CountPart(root -> GetPtr(j), 0, 0, 0, 0, 1);
  15. }else{
  16. counter = counter + CountPart(root -> GetPtr(j), 0, 0, 0, 0, 0);
  17. }
  18. }
  19. return counter;
  20. }
  21.  
  22. int Trie::CountPart(TrieNode* p, int a, int e, int i, int o, int u){
  23. int counter = 0;
  24. if(p == 0)
  25. return 0;
  26.  
  27. if(p -> GetPtr(0) != 0)
  28. a++;
  29. if(p -> GetPtr(4) != 0)
  30. e++;
  31. if(p -> GetPtr(8) != 0)
  32. i++;
  33. if(p -> GetPtr(14) != 0)
  34. o++;
  35. if(p -> GetPtr(20) != 0)
  36. u++;
  37.  
  38. for(int j = 0; j < TrieMaxElem; j++){
  39. counter = counter + CountPart(p -> GetPtr(j), a, e, i, o, u);
  40. }
  41.  
  42. if((p -> GetStrEnds()) && ((a+e+i+o+u) == 3))
  43. if(a == 0 || a == 1)
  44. if(e == 0 || e == 1)
  45. if (i == 0 || i == 1)
  46. if(o == 0 || o == 1)
  47. if(u == 0 || u == 1)
  48. counter++;
  49.  
  50. return counter;
  51. }
Add Comment
Please, Sign In to add comment