Advertisement
ahmad_zizo

print

May 29th, 2014
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. //كدة هيخلي الطباعة أحسن شوية
  2. void print_preorder(node_id* tree,int c)
  3. {
  4. if (tree && tree->id != ~(1<<31))
  5. {
  6. int i; for(i=0;i<c;i++) printf("\t");
  7. printf("%d %s\n", tree->id, tree->name);
  8. print_preorder(tree->left,c+1);
  9. print_preorder(tree->right,c+1);
  10. }
  11. else
  12. printf("\n");
  13. }
  14.  
  15.  
  16. void print_inorder(node_id* tree,int c)
  17. {
  18. if (tree && tree->id != ~(1<<31))
  19. {
  20. print_inorder(tree->left,c+1);
  21. int i;
  22. for(i=0; i<c; i++) printf("\t");
  23. printf("%d %s\n", tree->id, tree->name);
  24. print_inorder(tree->right,c+1);
  25. }
  26. else
  27. printf("\n");
  28.  
  29. }
  30.  
  31. void print_postorder(node_id* tree, int c)
  32. {
  33. if (tree && tree->id != ~(1<<31))
  34. {
  35. print_postorder(tree->left,c+1);
  36. print_postorder(tree->right,c+1);
  37. int i; for(i=0;i<c;i++) printf("\t");
  38. printf("%d s\n", tree->id, tree->name);
  39. }
  40. else
  41. printf("\n");
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement