文章
65
粉丝
25
获赞
661
访问
18.7k
#include <bits/stdc++.h>
using namespace std;
typedef struct node{
int data;
struct node *lchild,*rchild;
} *btree;
void ct(btree &T,int x,int father){//注意应使用引用!
if(T==NULL){
T=new node;
T->data=x;
T->lchild=NULL;
T->rchild=NULL;
cout<<father<<endl;
return;
}
if(x==T->data) return;
else if(x<T->data) ct(T->lchild,x,T->data);
else if(x>T->data) ct(T->rchild,x,T->data);
}
int main(){
int n;
while(cin>>n) {
btree T=NULL;
&nb...
登录后发布评论
这么写是哪里有问题啊,能请问下吗