摘要:
题目地址 题目分析:直接利用后序中序模拟出遍历过程,并按先序输出。 #include<stdio.h> int n,post[30],mid[30]; void pre(int postL,int postR,int midL,int midR) { int root=post[postR],rp; 阅读全文
posted @ 2023-03-12 15:24
kingdalf
阅读(46)
评论(0)
推荐(0)
摘要:
题目地址 题目分析:比较繁琐,因为符号和数字都要按字符处理,建议列一下顺序和各情况。 #include<stdio.h> int top=-1; char opChar[20]; void push(char c){ opChar[++top]=c; } char pop(void){ if(opC 阅读全文
posted @ 2023-03-12 15:19
kingdalf
阅读(35)
评论(0)
推荐(0)
摘要:
题目地址 题目分析: 分析数字变化,可以发现是一个深度优先过程。注意返回条件即可。 #include<stdio.h> int n,sum=0,stack[30],sTop=-1,flag=0; void DFS(int x); void push(int x){ stack[++sTop]=x,s 阅读全文
posted @ 2023-03-12 15:06
kingdalf
阅读(176)
评论(0)
推荐(0)
摘要:
题目地址题目分析:左左和右右直接处理,左右改左左,有右左改右右。 #include<stdio.h> #include<stdlib.h> #define max(a,b) ((a)>(b)?(a):(b)) typedef struct tree *tp; struct tree{ int dat 阅读全文
posted @ 2023-03-12 14:58
kingdalf
阅读(25)
评论(0)
推荐(0)
摘要:
题目分析:最小生成树问题,解法采取了Kruskal算法,利用qsort和并查集实现。8.5在8.4的基础上稍作调整即可。 #include<iostream> #include<stdlib.h> #include<string.h> using namespace std; typedef str 阅读全文
posted @ 2023-03-12 11:47
kingdalf
阅读(27)
评论(0)
推荐(0)