daily pastebin goal
41%
SHARE
TWEET

zadatak 2

a guest May 24th, 2018 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. struct CVOR
  6. {
  7.     int key;
  8.     struct CVOR*cvor_levo;
  9.     struct CVOR*cvor_desno;
  10. };
  11.  
  12. void dodaj(struct CVOR *i, int h)
  13. {
  14.     i->key = h;
  15. };
  16.  
  17. struct CVOR *create()
  18. {
  19.     struct CVOR* i = (struct CVOR*)malloc(sizeof(struct CVOR));
  20.     i->cvor_levo = 0;
  21.     i->cvor_desno = 0;
  22.     return i;
  23. };
  24.  
  25. void POSTORDER(struct CVOR *i)
  26. {
  27.     if (i->cvor_levo != 0)
  28.         POSTORDER(i->cvor_levo);
  29.     if (i->cvor_desno != 0)
  30.         POSTORDER(i->cvor_desno);
  31.     printf("%d ", i->key);
  32. };
  33.  
  34. void main(void)
  35. {
  36.     struct CVOR*koren;
  37.  
  38.     koren = create();
  39.     dodaj(koren, 4);
  40.  
  41.     koren->cvor_desno = create();
  42.     dodaj(koren->cvor_desno, 5);
  43.  
  44.     koren->cvor_levo = create();
  45.     dodaj(koren->cvor_levo, 2);
  46.  
  47.     koren->cvor_levo->cvor_levo = create();
  48.     dodaj(koren->cvor_levo->cvor_levo, 1);
  49.  
  50.     koren->cvor_levo->cvor_desno = create();
  51.     dodaj(koren->cvor_levo->cvor_desno, 3);
  52.  
  53.  
  54.     printf("%s\n", "POSTORDER:");
  55.     POSTORDER(koren);
  56.     printf("\n\n");
  57.  
  58.     system("pause");
  59.  
  60. }
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