Advertisement
fundor333

Asd 1

May 18th, 2016
1,879
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. typedef struct node{
  2.   int key,
  3.   struct node* left,
  4.   struct node* right,
  5. } *Node
  6.  
  7. typedefstruct nodet{
  8.   int key,
  9.   int diff,
  10.   struct nodet* left,
  11.   struct nodet* right,
  12. } *NodeT
  13.  
  14. NodeT funzionechiamante(node T)
  15. {
  16.   NodeT T1 = malloc(sizeof(NodeT));
  17.   funzionericorsiva(T,T1);
  18.   return T1;
  19. }
  20.  
  21. int funzionericorsiva(node T, nodet T1)
  22. {
  23.   T1.key = T.key;
  24.   T1.left = null;
  25.   T1.right = null;
  26.   T1.diff = 0;
  27.   int diff = 0;
  28.  
  29.   if (T.left != null)
  30.   {
  31.     T1.left = malloc(sizeof(NodeT));
  32.     diff =abs(diff- funzionericorsiva(T.left,T1.left));
  33.   }
  34.   if (T.right != null)
  35.   {
  36.     T1.right = malloc(sizeof(NodeT));
  37.     diff =abs(diff- funzionericorsiva(T.right,T1.right));
  38.   }
  39.  
  40.   T1.diff=diff;
  41.   return diff;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement