蒙神
春芽
共回答了14个问题采纳率:100% 举报
#include
#include
typedef struct node
{
int data;
node *left;
node *right;
}node;
node* CreateTree(node *root,int n)
{
if(root==NULL)
{
root=(node *)malloc(sizeof(node));
root->data=n;
root->left=NULL;
root->right=NULL;
return root;
}
else if(n>root->data)
{
root->right=CreateTree(root->right,n);
return root;
}
else if(ndata)
{
root->left=CreateTree(root->left,n);
return root;
}
}
void Print(node *root)
{
if(root!=NULL)
{
Print(root->left);
printf("%d ",root->data);
Print(root->right);
}
return;
}
bool search(node* root,int a)
{
node *p=root;
while(p!=NULL)
{
if(a==p->data)
return true;
else if(a>p->data)
p=p->right;
else if(adata)
p=p->left;
}
return false;
}
void del(char *c)
{
int i,j=0,k=0;
bool b=true;
for(i=0;c[i]!=' ';++i)
{
b=true;
k=0;
while(k
1年前
1