用二叉树表示表达式
摘要:
先看中缀表达式的二叉树表示: /* * 中缀表达式 构建 二叉树 * * 方法: 每次找到“最后计算”的运算符,作为当前树的根,然后递归处理 * 详见 刘汝佳《算法竞赛入门经典》 P198 * */#include <iostream>using namespace std;const int maxn = 1000;//每个节点的左右儿子编号int lch[maxn], rch[maxn];//节点的字符char op[maxn];//节点数int cnt = 0;//s的[x, y)作为范围int buildTree(char *s, int x, int y... 阅读全文
posted @ 2011-10-09 23:10 龙豆 阅读(9126) 评论(0) 推荐(1)
浙公网安备 33010602011771号