首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
cczz
加油
关注
发消息
文章
0
题解
74
发帖
0
笔记
0
Ta的粉丝
0
关注数
0
粉丝数
0
获赞数
182
阅读数
16907
【模板题】(递归,无需采用建树)给定二叉树中序和其他一种排序序列,求另一种排序序列题解:
#include<bits/stdc++.h> using namespace std; void PostOrder(string pre, string in){ if(pre.size() <= 0) return; else { char r...
P1561
2025年8月13日 21:33
回复 0
|
赞 2
|
浏览 228
判断二叉树是否对称 题解(两种方式:1.二叉树层次截取遍历 2.层次遍历建树,递归判断):
方法1:无需建树 #include<bits/stdc++.h> using namespace std; int main(){ string s; while(cin >> s){ int len = s.lengt...
P1551
2025年8月13日 21:20
回复 0
|
赞 4
|
浏览 261
已知前序遍历序列和中序遍历序列确定二叉树:(递归解决,简单易懂)
例题:若一棵二叉树的前序遍历为 ABCDEF,中序遍历为 CBAEDF,请画出这棵二叉树。 分析:前序遍历第一个输出结点为根结点,故 A 为根结点。早中序遍历中根结点处于左右子树 结点中间,故结点 A 的左子树中结点有 CB,右子树中结点有 EDF。 &nbs...
P1401
2025年8月13日 18:59
回复 0
|
赞 5
|
浏览 192
二叉树2 题解:
#include<bits/stdc++.h> using namespace std; void getNum(int m, int n, int &cnt){ if(m <= n){ cnt ++; getNum(m * 2, n, c...
P1264
2025年8月13日 18:17
回复 0
|
赞 2
|
浏览 152
二叉树 题解:
利用完全二叉树的性质:父节点 = 子节点 / 2 #include<bits/stdc++.h> using namespace std; int main(){ int x, y; ...
P1233
2025年8月13日 17:24
回复 0
|
赞 0
|
浏览 213
二叉树遍历 题解(注意idx传参需要采用&地址引用用,不可直接传值):
#include<bits/stdc++.h> using namespace std; typedef struct node{ char data; struct node *lchild, *rchild; }*BitTree; void Crea...
P1161
2025年8月12日 17:21
回复 0
|
赞 10
|
浏览 294
二叉树的建立和遍历(模板题) 题解:
#include<bits/stdc++.h> using namespace std; typedef struct node{ char data; struct node *lchild, *rchild; }*BitTree; // 创建二叉树 ...
P1109
2025年8月12日 16:47
回复 0
|
赞 5
|
浏览 218
哈夫曼树 题解(priority_queue解决):
#include<bits/stdc++.h> using namespace std; struct Node{ int x; Node(int a){x = a;} }; bool operator<(const Node &a, co...
P1382
2025年8月11日 19:32
回复 0
|
赞 6
|
浏览 233
括号匹配问题 题解(stack容器):
#include<bits/stdc++.h> using namespace std; void test(string s){ stack<char> st; int len = s.size(); char flag[105] = {0};...
P1296
2025年8月11日 18:04
回复 0
|
赞 1
|
浏览 211
括号的匹配 题解(stack和map容器):
#include<bits/stdc++.h> using namespace std; map<char, int> rk = {{'{', 4}, {'[', 3}, {'(', 2}, {'<', 1}}; map<char, char&...
P1067
2025年8月11日 17:39
回复 0
|
赞 8
|
浏览 327
大整数加法 题解(C++解法,模板题):
#include<bits/stdc++.h> using namespace std; string Add(string a, string b){ if(a.length() < b.length()) swap(a, b); string r...
P1474
2025年8月11日 12:28
回复 0
|
赞 0
|
浏览 221
最短距离 题解(一元二次方程抛物线):
#include<bits/stdc++.h> using namespace std; double minDistance(){ int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >...
P1679
2025年8月10日 18:15
回复 0
|
赞 0
|
浏览 193
切木棍 题解(找规律,三目运算符):
#include<bits/stdc++.h> using namespace std; void judege(int n){ if(n % 2 != 0){ cout << 0 << endl; return; } /...
P1674
2025年8月10日 17:50
回复 0
|
赞 0
|
浏览 200
有多少个点在直线上 题解:
#include<bits/stdc++.h> using namespace std; int cnt = 0; int xa, ya, xb, yb; void judge(int x, int y){ double res = 1.0*(ya - yb)*...
P5246
2025年8月10日 17:34
回复 0
|
赞 1
|
浏览 200
最大素因子 题解(素数筛):
#include<bits/stdc++.h> using namespace std; // 素数筛 const int maxn = 1000000 + 5; int prime[maxn]; void getPrime(){ memset(prime, ...
P1464
2025年8月9日 18:31
回复 0
|
赞 1
|
浏览 176
整除问题 题解(求质因子解法):
n!=1*2*3*...*n,所以n!的质因子就是1、2、3、...... 、n的质因子的集合 a^k=a*a*...*a,那么a^k的质因子的集合就是a的质因子集合乘k #include<bits/stdc++.h> using namespace ...
P1284
2025年8月9日 18:04
回复 0
|
赞 3
|
浏览 185
素数 题解(素数筛-模板题):
#include<bits/stdc++.h> using namespace std; // 素数筛模板getPrime,prime[0]存储素数的个数 const int maxn = 10000 + 5; int prime[maxn]; void getP...
P1375
2025年8月9日 16:54
回复 0
|
赞 2
|
浏览 235
素数判定 - 哈尔滨工业大学 题解:
#include<bits/stdc++.h> using namespace std; bool isPrime(int a){ if(a <= 1) return false; for(int i = 2; i <= sqrt(a); i ++)...
P1355
2025年8月9日 16:16
回复 0
|
赞 0
|
浏览 177
最大公约数和最小公倍数 题解:
#include<bits/stdc++.h> using namespace std; int gcd(int a, int b){ if(b==0) return a; return gcd(b, a % b); } int main(){ in...
P1041
2025年8月9日 16:00
回复 0
|
赞 0
|
浏览 171
最大公约数1 题解:
#include<bits/stdc++.h> using namespace std; int gcd(int a, int b){ if(b == 0) return a; else return gcd(b, a % b); } int main(...
P1426
2025年8月9日 15:55
回复 0
|
赞 0
|
浏览 182
1
2
3
4
本科学校:bilibili大学
目标学校:无
点此申请N诺身份认证
获得 noobdream 认证,享受多重认证福利!