Advertisement
vkichukova

Untitled

Jan 30th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. template<class T>
  2. void fillTree(vector<T> leaves, CompleteBinTree<T>& tree)
  3. {
  4. int size = leaves.size();
  5. int usedPositions[size] = {0};
  6. for(int i = 0; i < size; i++)
  7. cout << usedPositions[i] << " ";
  8.  
  9. int i = 0;
  10. while(!leaves.empty())
  11. {
  12. int position = -1; //
  13.  
  14. srand(time(NULL));
  15. position = rand() % leaves.size();
  16. cout << position << endl;
  17. if(inArray(usedPositions, size, position))
  18. continue;
  19.  
  20. usedPositions[i++] = position;
  21. tree.addElement(leaves[position]);
  22. myerase(leaves, position);
  23.  
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement