nato_fernandes

Untitled

Mar 1st, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include "bst.h"
  4.  
  5. void indent(int x, int key){
  6. if (x == 0){ printf("%d\n", key); }
  7. else { printf ("  ");
  8.        indent(x-1, key);
  9.        }
  10.  }
  11.  
  12. void printbst(BST t, int x){
  13.  
  14. if (t == NULL){ printf(""); }
  15. else{
  16.   printbst(BSTright(t), (x + 1));
  17.   indent(x, BSTkey(t));
  18.   printbst(BSTleft(t), (x + 1));
  19.   }
  20. }
  21.  
  22. int main(void){
  23.  
  24. BST x = BSTmake(2, (BSTmake( 1, NULL, NULL)), (BSTmake(3, NULL,NULL)));
  25. BST y = insertbst(4, x);
  26. printbst(y,0);
  27.  
  28.  
  29. BSTdestroy(y);
  30.  
  31. }
Add Comment
Please, Sign In to add comment