首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
阿宇羽
2026年3月25日 17:20
判断二叉树是否对称 题解:
P1551
回复 0
|
赞 6
|
浏览 121
#include <stdio.h> #include <stdlib.h> #include <string.h> //层次遍历的方式输入一个二叉树, //判断这个二叉树的结构(即不用管结点的值)是否镜像对称。 typedef struct node { char data; struct node *lchild,*rchild; } BitNode,*BitTree; //层序遍历创建二叉树,传入字符数组和数组大小 BitTree createTree(char *s,...
Ranz
2026年3月21日 19:26
判断二叉树是否对称 题解:
P1551
回复 0
|
赞 3
|
浏览 157
#include<bits/stdc++.h> using namespace std; typedef struct node{ char data; struct node *lchild, *rchild; }*BitTree; bool isSym(BitTree left, BitTree right){ if(left == NULL && right == NULL) return true; &n...
ljh61
2026年3月16日 16:25
判断二叉树是否对称 题解:
P1551
回复 0
|
赞 7
|
浏览 187
先构造一手再比较 #include<bits/stdc++.h> using namespace std; struct TreeNode{ char val; struct TreeNode *left,*right; TreeNode(char val):val(val),left(NULL),right(NULL){} }; TreeNode *build(const string& s){  ...
sky952
2026年3月13日 15:52
判断二叉树是否对称 题解(c语言,递归实现)
P1551
回复 0
|
赞 13
|
浏览 217
#include <stdio.h> #include <string.h> char s[1005]; int n; int mirror(int i, int j) { if (i >= n && j >= n) return 1; if (i >= n || j >= n) { if (i >= n && s[j] == '...
uly
2026年3月6日 12:33
判断二叉树是否对称 题解:
P1551
回复 0
|
赞 6
|
浏览 212
#include <bits/stdc++.h> using namespace std; bool is_match(char a ,char b) { if ((isalpha(a)&&isalpha(b))||(a=='#'&&b=='#')) return true; else return false; } bool if_sym(string str) { int len=str.length(); if(len==0) return false; if (len...
cczz
2025年8月13日 21:20
判断二叉树是否对称 题解(两种方式:1.二叉树层次截取遍历 2.层次遍
P1551
回复 0
|
赞 63
|
浏览 1.4k
方法1:无需建树 #include<bits/stdc++.h> using namespace std; int main(){ string s; while(cin >> s){ int len = s.length(); int depth = 1; // 当前层数 bool flag = true; // 此层是否对称 while(len >= pow(2, depth) - 1){ // 截取单层 int level_len = pow(2, depth ...
yukina
2025年5月10日 19:54
判断二叉树是否对称 题解:
P1551
回复 0
|
赞 13
|
浏览 947
//通过判断字符串对称性来解决 #include <iostream> #include <string> using namespace std; //检查对称性 bool checkSymmetry(string ss) { int lens = ss.size(); for (int i = 0; i < lens / 2; i++) { if ((ss[i] != '#') != (ss[lens - 1...
XCR553
2025年4月10日 10:34
判断二叉树是否对称 题解:
P1551
回复 0
|
赞 8
|
浏览 1.2k
//看了好几个都没有我的解法简单 #include <bits/stdc++.h> using namespace std; int main(){ string s; cin >> s; int id = 0; bool flag = true; for(int power = 0; id < s....
zzu543
2025年3月16日 21:58
判断二叉树是否对称 题解:
P1551
回复 0
|
赞 6
|
浏览 1.3k
#include <stdio.h> #include <stdlib.h> #include <string.h> //统计#的数量 int calc(char temp[], int index){ int count = 0; for(int i = 0; i < index; i++){ if(temp[i] == '#'){ &n...
carrot_huan
2025年3月13日 23:47
判断二叉树是否对称 题解:第一步根据完全二叉树的性质递归建树,第二步递
P1551
回复 0
|
赞 24
|
浏览 1.6k
#include<iostream> #include<string> using namespace std; struct TNode { char data; TNode* rchild, * lchild; }; void BuildTree(string str,int index, struct TNode* &root) { if (index >= str.size(...
1
2
3
题目
判断二叉树是否对称
题解数量
27
发布题解
在线答疑
热门题解
1
判断二叉树是否对称 题解(两种方式:1.二叉树层次截取遍历 2.层次遍历建树,递归判断):
2
判断二叉树是否对称 题解:
3
判断二叉树是否对称 题解:第一步根据完全二叉树的性质递归建树,第二步递归判定树是否镜像对称
4
判断二叉树是否对称 题解:无需建树
5
判断二叉树是否对称 题解:新手方法 易于理解
6
判断二叉树是否对称 简单解法 无需建树,一层一层判断
7
判断二叉树是否对称 (指针建树)题解:
8
判断二叉树是否对称 题解:
9
判断二叉树是否对称 题解(c语言,递归实现)
10
判断二叉树是否对称 题解: