Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.82 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. struct node{
  4.     int mn;
  5.     struct node *ad;
  6. };
  7.  
  8. struct node *n1;
  9. int ct=0,s;
  10.  
  11. void rec(struct node *n1)
  12. {
  13.     ct++;
  14.     scanf("%d",&n1->mn);
  15.     if(ct<=3){
  16.         n1->ad=(struct node *)malloc(s);
  17.         rec(n1->ad);
  18.     }
  19. }
  20.  
  21.  
  22. int main()
  23. {
  24.     s=sizeof(struct node);
  25.     n1=(struct node *)malloc(sizeof(struct node));
  26.     rec(n1);
  27.     /*n1=(struct node *)malloc(sizeof(struct node));
  28.     scanf("%d",&n1->mn);
  29.     n1->ad=(struct node *)malloc(sizeof(struct node));
  30.     scanf("%d",&n1->ad->mn);
  31.     n1->ad->ad=(struct node *)malloc(sizeof(struct node));
  32.     scanf("%d",&n1->ad->ad->mn);
  33.     n1->ad->ad->ad=(struct node *)malloc(sizeof(struct node));
  34.     scanf("%d",&n1->ad->ad->ad->mn);*/
  35.     printf("%d %d %d %d\n",n1->mn,n1->ad->mn,n1->ad->ad->mn,n1->ad->ad->ad->mn);
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement