Advertisement
Guest User

Dla Damiana

a guest
Nov 23rd, 2014
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 KB | None | 0 0
  1. void wstaw(struct Wezel *start, int wartosc)
  2. {
  3.     if(root == NULL)
  4.     {
  5.         root = (struct Wezel *)malloc(sizeof(struct Wezel));
  6.         root->wartosc = wartosc;
  7.         root->lewySyn = NULL;
  8.         root->prawySyn = NULL;
  9.         root->rodzic = NULL;
  10.     }
  11.  
  12.     else if(wartosc < start->wartosc)
  13.     {
  14.         if(start->lewySyn != NULL)
  15.             wstaw(start->lewySyn, wartosc);
  16.         else
  17.         {
  18.             struct Wezel *nowy = (struct Wezel *)malloc(sizeof(struct Wezel));
  19.             nowy->wartosc = wartosc;
  20.             nowy->lewySyn = NULL;
  21.             nowy->prawySyn = NULL;
  22.             nowy->rodzic = start;
  23.             start->lewySyn = nowy;
  24.         }
  25.     }
  26.     else
  27.     {
  28.         if(start->prawySyn != NULL)
  29.             wstaw(start->prawySyn, wartosc);
  30.         else
  31.         {
  32.             struct Wezel *nowy = (struct Wezel *)malloc(sizeof(struct Wezel));
  33.             nowy->wartosc = wartosc;
  34.             nowy->lewySyn = NULL;
  35.             nowy->prawySyn = NULL;
  36.             nowy->rodzic = start;
  37.             start->prawySyn = nowy;
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement