首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
yourgaba233
2026年3月12日 18:39
二叉树遍历 C语言题解:递归查找位置插入
P1161
回复 0
|
赞 2
|
浏览 16
#include <stdio.h> #include <stdlib.h> typedef struct TNode{//结点 char id; struct TNode* lchild; struct TNode* rchild; }TNode,*Tree; int creatNode(Tree* T,char c){//通过根结点找到合适位置,插入结点 TNode* child; if(*T==...
Jinx_K
2026年3月11日 20:39
二叉树遍历 题解:CreateBT(BiTree &T,int &po
P1161
回复 0
|
赞 3
|
浏览 36
#include <iostream> #include <cstdio> #include <string> using namespace std; typedef struct BTNode { char c; struct BTNode* lc, * rc; }BTNode, * BiTree; void CreateBT(BiTree& T, int& pos, string &s) { if (pos >= s.size()) return; char temp; ...
白米饭607
2026年3月6日 00:17
二叉树遍历 题解:
P1161
回复 0
|
赞 18
|
浏览 198
//非常需要耐心的一道题 先建树,再遍历(可以再加一步free不过我没加), 然后修改输入 //每棵树完事 切记要清空字符串!!! //建造树用的是递归 要仅考虑该结点的处理 不要过度思考左右结点的处理 会把自己绕进去 #include <stdio.h> #include <vector> using namespace std; struct TreeNode { char data; struct TreeNode* left;  ...
uly
2026年3月5日 20:46
二叉树遍历 题解:
P1161
回复 0
|
赞 5
|
浏览 87
#include <bits/stdc++.h> using namespace std; #define ll long long typedef struct Node { char data; struct Node *left,*right; }*Btree; string s; int counta; //先序遍历创建 void CreatBinaryTree(Btree &B) { char c; cin>>c; if (c=='#') B=NULL; el...
白米饭607
2026年3月4日 16:54
二叉树遍历 题解:
P1161
回复 0
|
赞 5
|
浏览 79
//有多组数据 记得 在一次输出之后 换行 我因为这个换行改了好久 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #include <stdio.h> #include <string> using namespace std; struct TreeNode { //树的结构体 char data; struct TreeNode *left; struct TreeNode *right; }; void bu...
bro
2026年2月26日 16:44
二叉树遍历 题解:c++
P1161
回复 0
|
赞 12
|
浏览 169
#include <bits/stdc++.h> using namespace std; string s; int i; typedef struct Node{ char data; Node *left,*right; }*Tree; void CreateTree(Tree &t){ if(i >= s.size()){ t = nullptr; ret...
isnotlnln
2026年2月12日 12:38
二叉树遍历 题解:回溯建树+递归遍历
P1161
回复 0
|
赞 14
|
浏览 208
#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()...
xsw
2026年2月8日 19:05
二叉树遍历 题解:
P1161
回复 0
|
赞 8
|
浏览 295
#include<iostream> using namespace std; void dfs(string s, int &k) { if (s[k] == '#' || k >= s.size()) { k ++ ; return; } char t = s[k ++ ]; dfs(s, k); cout << t << ' '; dfs(s, k); } int main() { string s; while (cin >> s) { in...
mlx
2026年1月26日 19:17
二叉树遍历 题解:
P1161
回复 0
|
赞 5
|
浏览 216
#include<iostream> using namespace std; struct tr{ char c; tr *l; tr *r; }; string str; int k; void init(tr* &t) { if(k==str.size()) { t=nullptr; return; } if(str[k]=='#') { t=nullptr; k++; } ...
cczz
2025年8月12日 17:21
二叉树遍历 题解(注意idx传参需要采用&地址引用用,不可直接传值):
P1161
回复 0
|
赞 20
|
浏览 977
#include<bits/stdc++.h> using namespace std; typedef struct node{ char data; struct node *lchild, *rchild; }*BitTree; void CreateBitTree(BitTree &T, string &s, int &idx){ if(idx >= s.length()){T = NULL; return;} char c = s[idx++]; if(c != '#'){ T = n...
1
2
3
4
题目
二叉树遍历
题解数量
40
发布题解
在线答疑
热门题解
1
二叉树遍历 题解:
2
二叉树遍历 题解:难点在于题目输入的字符串最后‘#’不够,导致没做完树,没有返回
3
二叉树遍历 题解:
4
套用教材模板,同时解决RunTime ERROR
5
二叉树遍历 题解(注意idx传参需要采用&地址引用用,不可直接传值):
6
二叉树遍历 题解:整段输入如何传参?全局变量解答
7
二叉树遍历 题解:c++注意超时问题
8
二叉树遍历 题解:
9
二叉树遍历 题解:新手题解,勿喷
10
二叉树遍历 题解: