#include<stdio.h>
#include<conio.h>
struct s
{
int i;
struct s *q,*w,*e;
};
main()
{
struct s *r,*t,*y;
int j=0,a;
while(1)
{
//printf("qwereqr");
scanf("%d",&a);
if(a!=123)
{
//printf("\nqwereqr1");
if(j==0)
{
t=malloc(sizeof((struct s*)r));
t->i=a;
t->q=t->w=t->e=NULL;
printf("r=%d ",t->i);
j++;
}
else
{
y=t;
while(y!=NULL)
{
/// printf("\nqwereqr2");
r=y;
if(a>(y->i))
y=y->w;
else
y=y->q;
}
y=malloc(sizeof((struct s*)y));
if(r->i<a)
{
r->w=y;
r->w->i=a;
r->w->q=r->w->w=NULL;
r->w->e=r;
printf("ri=%d ",r->w->i);
}
else
{
r->q=y;
r->q->i=a;
r->q->q=r->q->w=NULL;
r->q->e=r;
printf("l=%d ",r->q->i);
}
}
}
else
break;
}
}
Your code is highly unreadable. Please put in proper blocks or give the ideone link.
1 Like