Advertisement
Kevin_Zhang

Untitled

Nov 14th, 2021
925
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.43 KB | None | 0 0
  1. #include "node.h"
  2. #include <stdio.h>
  3.  
  4. typedef Node* Node_ptr
  5.  
  6. void my_print(Node_ptr *root_ptr) {
  7.     Node root = *root_ptr;
  8.     if (root == NULL) return;
  9.     printf("%d", root->data);
  10.     if (root->left != NULL)
  11.         my_print(&(root->left));
  12.     else
  13.         my_print(&(root->right));
  14.  
  15.     if (root->left == NULL && root->right == NULL)
  16.         *root_ptr = NULL;
  17. }
  18. void print_all_paths(Node *root) {
  19.     while (*root != NULL)
  20.         my_print(&root);
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement