expressio专题

7-3 Postfix Expressio (25 分)

考查的知识点: 只有右子树的时候需要特殊处理 #include <iostream>#include <cmath>#include <algorithm>#include <vector>#include <string>using namespace std;const int N = 25;int Root = 1;struct node{string val;int le

1130 Infix Expressio (25 分)

之前因为偷懒没有刷这道题,结果秋季的PAT考试就考到了。 主要是理解括号的插入位置以及遍历的规则。 首先需要找到根节点,其次是非根节点和叶子点需要加括号。 #include <iostream>#include <cmath>#include <algorithm>#include <vector>#include <string>using namespace std;const