Advertisement
Guest User

noprint

a guest
Feb 7th, 2016
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.98 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. /* typedef for a list structure */
  5. typedef struct l_node *LPtr;
  6. typedef struct l_node {
  7.     int wert;
  8.     LPtr next;
  9. } l_nodetype;
  10.  
  11.  
  12. /* Typedef for a tree structure */
  13. typedef struct t_node *BRtr;
  14. typedef struct t_node {
  15.     int wert;
  16.     BRtr right, left;
  17. } t_nodetype;
  18.  
  19.  
  20. /* builds tree off list */
  21. BRtr full(LPtr l){
  22.     BRtr baum;
  23.     if(l==NULL){
  24.         return NULL;
  25.     } else {
  26.     baum = (BRtr) malloc(sizeof(t_nodetype));
  27.     baum->wert =(int) l->wert;
  28.     baum->left = full(l->next);
  29.     baum->right = full(l->next);
  30.         return baum;
  31.     }    
  32. }
  33.  
  34.  
  35. void main() {
  36.    
  37.     printf("first print\n");
  38.  
  39.     /* declare some list elements*/
  40.     LPtr le1;
  41.     LPtr le2;
  42.     LPtr le3;
  43.     /* declare tree element */
  44.     BRtr t;
  45.    
  46.     le1->wert = 3;
  47.     le1->next = le2;
  48.    
  49.     le2->wert = 3;
  50.     le2->next = le3;
  51.  
  52.     /* assign the new tree to t */
  53.     t = full(le1);
  54.  
  55.     printf("secound print\n");
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement