运行结果正确

#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#include<malloc.h>
//构造结构树
typedef struct node *tree;
struct node{
int val;
int flag;
tree left;
tree right;
};
//遍历
void pre_tra(tree t){
tree t1=t;
if(t1==NULL){
return;
}
printf("%d ",t1->val);
pre_tra(t1->left);
pre_tra(t1->right);
}
//新建节点
tree creat_node(int val){
tree t=(tree)malloc(sizeof(struct node));
t->val=val;
t->left=t->right=NULL;
t->flag=0;
return t;
}
//插入
tree insert(tree t,int val){
if(t==NULL){
t

本文介绍了如何使用C语言编写算法,判断两个二叉树是否互为二叉搜索树的镜像,即是否是同一棵二叉搜索树。通过递归比较每个节点的值和相对位置,确保符合二叉搜索树的特性。
最低0.47元/天 解锁文章
824

被折叠的 条评论
为什么被折叠?



