Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- struct node{
- int mn;
- struct node *ad;
- };
- struct node *n1;
- int ct=0,s;
- void rec(struct node *n1)
- {
- ct++;
- scanf("%d",&n1->mn);
- if(ct<=3){
- n1->ad=(struct node *)malloc(s);
- rec(n1->ad);
- }
- }
- int main()
- {
- s=sizeof(struct node);
- n1=(struct node *)malloc(sizeof(struct node));
- rec(n1);
- /*n1=(struct node *)malloc(sizeof(struct node));
- scanf("%d",&n1->mn);
- n1->ad=(struct node *)malloc(sizeof(struct node));
- scanf("%d",&n1->ad->mn);
- n1->ad->ad=(struct node *)malloc(sizeof(struct node));
- scanf("%d",&n1->ad->ad->mn);
- n1->ad->ad->ad=(struct node *)malloc(sizeof(struct node));
- scanf("%d",&n1->ad->ad->ad->mn);*/
- printf("%d %d %d %d\n",n1->mn,n1->ad->mn,n1->ad->ad->mn,n1->ad->ad->ad->mn);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement