- 博客(9)
- 问答 (2)
- 收藏
- 关注
原创 【数据结构】【二叉树】已知先序和中序遍历,求后序遍历
【数据结构】【二叉树】已知先序和中序遍历,求后序遍历 #include <bits/stdc++.h> using namespace std; void fn(string pre,string in) { //输入的先序和中序都为空 if(pre == "\0" || in == "\0"){ return ; } //根据先序找到根节点 x=pre[0] //根据x,找到在中序的位置 int pos = in.find( pre[0] ); //按后序输出 /
2022-05-18 19:26:34
610
原创 【二叉树】已知中序遍历、按层遍历,求先序、后序遍历
【二叉树】已知中序遍历、按层遍历,求先序、后序遍历 #include <bits/stdc++.h> using namespace std; string z,c; void dfs(int z_left,int z_right,string cc) { if(cc.length()<=0){ return ; }else { char root=cc[0];//层次遍历的第一个,就是根节点 int mid=z.find(root); string left_tre
2022-05-07 16:45:02
860
原创 【串】字符串匹配 Brute-Force 暴力搜索 C++
串 字符串匹配 Brute-Force C++ s1=“helloyouoo” s2=“you” s1从i=0开始,s2从j=0开始 当发现s1[i]==s2[j]时,继续进行匹配i++ j++;当发现不相等时,i退回到刚开始寻找的下一个位置,j又从头开始找j=0 #include <bits/stdc++.h> using namespace std; int main() { //字符串匹配 string s1="helloyouoo",s2="you"; int i=0;
2022-04-14 14:55:23
1348
原创 【队列】 限制转弯次数的迷宫
队列 限制转弯次数的迷宫 BFS C++ 输入:num测试数据组数,n行 m列,k最多可转弯次数,sy sx起点坐标,ey ex终点坐标 2 5 5 …** *.. … … … 1 1 1 1 3 5 5 … *.*. … … *… 2 1 1 1 3 输出: no yes 要把所有可走的点,按照同一个方向,依次入队和出队 入队顺序(1,1) (1,2) (1,3) (2,2) (3,2) (4,2) (5,2)… 确保一个方向转弯+1 next.s=top.s+1 #include &l
2022-04-10 10:30:41
832
原创 【队列】 象棋中的马 BFS C++ (接上一篇文章)
队列 象棋中的马 BFS C++ 不同于迷宫,迷宫中有通道和障碍;而象棋中的马则没有明显标记的通道和障碍。 因此要标记该点是否入过队 inq[x][y]={false}; 默认没有入过队 输入:x1,y1起点坐标 x2,y2终点坐标 5 4 7 8 输入:需要走的步数 2 #include <bits/stdc++.h> using namespace std; int step[10][11]={0}; //输入起点、终点 int sx,sy,ex,ey; bool inq[10][11]
2022-04-09 13:35:53
1023
原创 【队列】迷宫 BFS C++
队列 迷宫 C++ 输入:S起点;G终点;#墙壁;. 通道 5 5 #S### …##. #.### …### …G## 输出: The min steps are:5! #include <bits/stdc++.h> using namespace std; typedef struct point{ int x; int y; int step; }node; char maze[55][55]; int n,m; int sx,sy,ex,ey;//记录起点和终点坐标 int
2022-04-03 18:11:42
1225
原创 【栈】计算器 C++(接上一篇文章)
栈 计算器 (接上一篇文章) 考虑负数 for(i=0;i<c.length()-1;i++){ char x=c[i]; if((x>='0' && x<='9') || (x=='-' && c[i-1]=='(')){ int a,b; if(x=='-'){ a=-1;//数字正负 b=0; }else { a=1; b=x-'0'; } int j=i+1
2022-04-03 14:59:48
380
原创 【栈】计算器 C++
栈 计算器 C++ 输入:1+(3+2)(7^2+69)/(2) 输出:258 在输入的字符串两端加上(),变成(1+(3+2)(7^2+69)/(2)) 定义两个栈:存放数字 stack s1;存放符号 stack s2; 给运算符指定优先级:+ - 1级;* / 2级;^ 3级;其余0级 当遇到运算符时,通过运算符的优先级,来判断是否优先运算 while(lev(x) <= lev(s2.top()) ){ calc(); } 当遇到)时,要一直把括号内的数据全部运算完毕 while(s2.
2022-04-02 19:33:27
671
原创 品优购案例 html css
品优购页面 分为三个页面,分别是 首页(index) 列表页(list) 注册页(register) favicon TDK 首页 列表页 注册页 base.css /*初始化*/ * { padding: 0; margin: 0; box-sizing: border-box; } li { list-style: none; } input,button { outline: none; } a { text-decoration: none;
2022-03-06 15:12:45
582
空空如也
微信小程序 合法域名配置 哪里有错啊
2022-04-22
PAT:换个格式输出整数 哪里有错啊
2021-10-01
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅