Advertisement
huutho_96

Code câu 1

Jun 11th, 2015
559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. using namespace std;
  4. struct Node
  5. {
  6.     int x;
  7.     Node *pLeft, *pRight;
  8. };
  9.  
  10. typedef Node * Tree;
  11. void Count_la(Tree T, int &dem)
  12. {
  13.     if (T != NULL)
  14.     {
  15.         if (T->pLeft == NULL && T->pRight == NULL) dem++;
  16.         Count_la(T->pLeft, dem);
  17.         Count_la(T->pRight, dem);
  18.     }
  19. }
  20. Node * Search_node(Tree T, int key)
  21. {
  22.     if (T != NULL)
  23.     {
  24.         if (T->x == key) return  T;
  25.         if (T->x > key) return Search_node(T->pLeft, key);
  26.         else return Search_node(T->pRight, key);
  27.     }
  28.     return NULL;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement