Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- /* typedef for a list structure */
- typedef struct l_node *LPtr;
- typedef struct l_node {
- int wert;
- LPtr next;
- } l_nodetype;
- /* Typedef for a tree structure */
- typedef struct t_node *BRtr;
- typedef struct t_node {
- int wert;
- BRtr right, left;
- } t_nodetype;
- /* builds tree off list */
- BRtr full(LPtr l){
- BRtr baum;
- if(l==NULL){
- return NULL;
- } else {
- baum = (BRtr) malloc(sizeof(t_nodetype));
- baum->wert =(int) l->wert;
- baum->left = full(l->next);
- baum->right = full(l->next);
- return baum;
- }
- }
- void main() {
- printf("first print\n");
- /* declare some list elements*/
- LPtr le1;
- LPtr le2;
- LPtr le3;
- /* declare tree element */
- BRtr t;
- le1->wert = 3;
- le1->next = le2;
- le2->wert = 3;
- le2->next = le3;
- /* assign the new tree to t */
- t = full(le1);
- printf("secound print\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement