Advertisement
4eyes4u

Untitled

Jan 16th, 2017
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <cstdlib>
  3.  
  4. struct cvor
  5. {
  6.     int val;
  7.     cvor *l, *r;
  8. } *root;
  9.  
  10. void umetni (cvor **root, cvor *x)
  11. {
  12.     if (*root==NULL)
  13.     {
  14.         *root=x;
  15.         x->l=NULL;
  16.         x->r=NULL;
  17.     }
  18.     else if (x->val < (*root)->val) umetni(&(*root)->l, x);
  19.     else umetni(&(*root)->r, x);
  20. }
  21.  
  22. int main()
  23. {
  24.     int x;
  25.     while (scanf ("%d", &x));
  26.     {
  27.         int x;
  28.         scanf ("%d", &x);
  29.         cvor *novi=(cvor *)malloc(sizeof (cvor));
  30.         novi->val=x;
  31.         umetni (&root, novi);
  32.     }
  33.  
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement