#include #include typedef struct BiTNode{ int data; struct BiTNode *lchild,*rchild;}BiTNode,*BiTree;int main(){ int n,t,i; int a[100]={0}; BiTree T=(BiTree)malloc(sizeof(BiTNode)); BiTree s,p; while(scanf("%d",&n)!=EOF) { if(n<1||n>100) continue; scanf("%d",&t); T->data=t; T->lchild=NULL; T->rchild=NULL; a[0]=-1; for(i=1;i data=t; p->lchild=NULL; p->rchild=NULL; s=T; while(1) { if(s->data>t&&s->lchild!=NULL) s=s->lchild; if(s->data>t&&s->lchild==NULL) break; if(s->data rchild!=NULL) s=s->rchild; if(s->data rchild==NULL) break; } a[i]=s->data; if(s->data>t) s->lchild=p; else s->rchild=p; } for(i=0;i
真是被这道题整死了。本来是道简单题。因为最后一个for循环i自增写成n自增…………