首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
ljh61
2026年3月13日 16:19
二叉树的建立和遍历 题解:
P1109
回复 0
|
赞 6
|
浏览 122
三种遍历方式+层序遍历 #include<bits/stdc++.h> using namespace std; struct TreeNode{ char val; struct TreeNode *left,*right; TreeNode(char c):val(c),left(NULL),right(NULL){} }; TreeNode* build(const string& s,int& index){ &nbs...
Jinx_K
2026年3月11日 20:51
二叉树的建立和遍历 题解:遍历一条龙
P1109
回复 0
|
赞 7
|
浏览 94
#include <iostream> #include <cstdio> #include <string> using namespace std; int count=0; typedef struct BTNode { char c; struct BTNode* lc, * rc; }BTNode, * BiTree; void CreateBT(BiTree& T) { char temp; cin>>temp; if (temp == '0') T = NULL; ...
uly
2026年3月5日 20:00
二叉树的建立和遍历 题解:
P1109
回复 0
|
赞 12
|
浏览 153
#include <bits/stdc++.h> using namespace std; #define ll long long ; typedef struct Node { char data; struct Node *left,*right; }*Btree; //先序遍历创建 void CreatBinaryTree(Btree &B) { char c; cin>>c; if (c=='0') B=NULL; else { B = new ...
bro
2026年2月26日 16:04
二叉树的建立和遍历 题解:c++,写了层序
P1109
回复 0
|
赞 8
|
浏览 111
#include <bits/stdc++.h> using namespace std; //定义二叉树 typedef struct Node{ char data; Node *l,*r; }*Tree; //先序遍历的方式创建二叉树 void CreateTree(Tree &t){ char c; cin >> c; if(c == '0') t = nullptr;...
isnotlnln
2026年2月22日 17:38
二叉树的建立和遍历 题解:
P1109
回复 0
|
赞 4
|
浏览 137
#include <iostream> #include <string> using namespace std; struct TNode{ char data; TNode *lchild,*rchild; }; int index=0; TNode* CreateTree(const string &s) { if(index>=s.size()) return nullptr; else if(s[index]=='0'){index++;return nullptr;} else{ T...
mlx
2026年1月26日 20:53
二叉树的建立和遍历 题解:
P1109
回复 0
|
赞 4
|
浏览 265
#include<iostream> using namespace std; struct tr{ char c; tr *l; tr *r; }; int num; void init(tr* &t) { char c; if(cin>>c) { if(c=='0') { t=nullptr; return; } else { t=new tr; t->c=c; init(t->l),init(t->r); } ...
cczz
2025年8月12日 16:47
二叉树的建立和遍历(模板题) 题解:
P1109
回复 0
|
赞 20
|
浏览 741
#include<bits/stdc++.h> using namespace std; typedef struct node{ char data; struct node *lchild, *rchild; }*BitTree; // 创建二叉树 void CreateBitTree(BitTree &T){ char c; cin >> c; if(c == '0') T = NULL; else { T = new node; T->data = c; CreateBitTree(...
leo110
2025年5月18日 15:47
二叉树的建立和遍历 题解:只看题注,没看输出要求,所以把二叉树的相关功
P1109
回复 0
|
赞 7
|
浏览 930
#include<iostream> #include<string> #include<queue> #include<vector> #include<algorithm> using namespace std; //二叉树结构 typedef struct node{ char data; struct node *lchild,*rchild; }*BiTree; //先序遍历的方式建立二叉树 void CreateBiT...
阿灿
2025年3月25日 15:49
二叉树的建立和遍历 题解:
P1109
回复 0
|
赞 17
|
浏览 1.1k
#include<bits/stdc++.h> using namespace std; typedef struct Node{ char c; struct Node *lchild,*rchild; }*Tree; Tree create(Tree &T){ char c; cin>>c; if(c=='0'){ T=NULL; } else { T = new Node; T->c = c; T->lchild=NULL; T->rchild=NULL; ...
shiv15832
2025年3月18日 13:06
二叉树的建立和遍历 题解:代码注释讲解
P1109
回复 0
|
赞 28
|
浏览 1.8k
树里面大量运用指针,基础不好的同学可能难以理解,结合代码注释讲一讲 #include<bits/stdc++.h> using namespace std; typedef struct node{//定义结构体node,并且将这种结构体命名为Node,指向它的指针命名为BiTree char data; struct node *lchild; struct node *rchild; }Node,*BiTree; BiTree ...
1
2
3
题目
二叉树的建立和遍历
题解数量
21
发布题解
在线答疑
热门题解
1
二叉树的建立和遍历 题解:修改先序遍历简化求叶子结点个数
2
二叉树的建立和遍历 题解:
3
二叉树的建立和遍历 题解:代码注释讲解
4
二叉树的创建方法值得关注
5
二叉树的建立和遍历(模板题) 题解:
6
二叉树的建立和遍历 题解:
7
二叉树的建立和遍历 题解:C++
8
二叉树的建立和遍历 题解:
9
加了一个层序遍历
10
二叉树的建立和遍历 题解:c++,写了层序