SHARE
TWEET

Untitled

a guest Jan 24th, 2020 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3. struct drzewko {
  4. int wewa;
  5. drzewko* left;
  6. drzewko* right;
  7. };
  8.  
  9. void wstaw(drzewko * & el, const int & wart) {
  10.     if (!el->wewa)
  11.         el->wewa = wart;
  12.     else if (wart < el->wewa)
  13.         if (el->left == nullptr)
  14.             el->left = new drzewko{ wart };
  15.         else wstaw(el->left, wart);
  16.     else if (wart >= el->wewa)
  17.         if (el->right == nullptr)
  18.             el->right = new drzewko{ wart };
  19.         else wstaw(el->right, wart);
  20. }
  21. int main(){
  22.     drzewko* el = new drzewko;
  23.     wstaw(el, 8);
  24.     wstaw(el, 87);
  25.     wstaw(el, 36);
  26.     szukaj
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top