摘要:
数据结构上机测试4.1:二叉树的遍历与应用1View Code #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAXN 200 void build(int n, char *s1, char *s2, char *s){ if(n<=0) return; int p = strchr(s2, s1[0]) - s2; build(p, s1+1, s2, s); build(n-p-1, s1+p+1, s2+p+1, s+p); s[n-... 阅读全文
posted @ 2013-02-19 15:13
Still_Raining
阅读(206)
评论(0)
推荐(0)
摘要:
第一种:Tree q[MAXN];void InOrderTraverse(Tree T){ int top = 0; Tree p = T; while(p || top != 0){ if(p) {q[top++] = p; p = p->lchild;}//根指针进栈,遍历左子树 else{ //根指针退栈,访问根结点,遍历右子树 p = q[--top]; printf("%c", p->data); p = p->rchild; } }}第二种:Tr... 阅读全文
posted @ 2013-02-19 15:08
Still_Raining
阅读(188)
评论(0)
推荐(0)
摘要:
题目链接。解题报告:这是很久前做的了。。又扒出来了。。怕再忘了嘛。。很简单。建立表达式树,然后后序遍历。代码如下:#include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> #define MAXN 200 int comp(char a, char b); int st1[MAXN], st2[MAXN]; int main(){ int top1 = 0, top2 = 0, i=0; char s[MAXN]; scanf("%s&qu 阅读全文
posted @ 2013-02-19 09:33
Still_Raining
阅读(500)
评论(0)
推荐(0)
浙公网安备 33010602011771号