文章
43
粉丝
24
获赞
292
访问
6.5k
#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...
登录后发布评论
暂无评论,来抢沙发