文章
145
粉丝
217
获赞
21
访问
83.9k
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct node{
char data;
struct node *lchild,*rchild;
}BiTNode,*BiTree;
//根据序列建立搜索树
void CreateTree(BiTree &T,char c)
{
if(!T)
{
T = (BiTNode *)malloc(sizeof(BiTree));
T->data = c;
T->rchild = NULL;
T->lchild = NULL;
return;
}
if(c == T->data)
return;
else if(c > T->data) CreateTree(T->rchild,c);
else CreateTree(T->lchild,c);
}
int Judge(BiTree T1,BiTree T2)
{
int like1,like2;
if(T1 == NULL && T2 == NULL) return 1;
else if(T1 == NULL || T2 == NULL || T1->data != T2->data)
return 0;
else
{
like1 = Judge(T1->lchild,T2->lchild);
like2 = Judge(T1->rchild,T2->rchild);
return like1 && like2;
}
}
int main()
{
int n,i,j,a[21],k;
char s[1000],s1[1000];
while(scanf("%d",&n) != EOF)
{
if(n == 0) break;
scanf("%s",s);
//建树
BiTree T1;
T1 = NULL;
...
登录后发布评论
暂无评论,来抢沙发