标签:编写 cto struct turn ack span pos class ==
已知如下信息,补充函数,返回二叉树的后序遍历。
struct Node{ int val; Node *left, *right; }; vector<int> get_postorder(Node *root){ ... }
vector<int> get_postorder(Node *root){ vector<int> v; if(root == NULL) return v; v = get_postorder(root -> left); vector<int> tmp = get_postorder(root -> right); int len = tmp.size(); for(int i = 0; i < len; ++i){ v.push_back(tmp[i]); } v.push_back(root -> val); return v; }
标签:编写 cto struct turn ack span pos class ==
原文地址:https://www.cnblogs.com/tyty-Somnuspoppy/p/9775429.html