// 非递归方式:堆栈,难点voidtravesal(TreeNode* p){
stack<TreeNode*> s;
TreeNode* cur = root;
TreeNode* pre =nullptr;while(cur ||!s.empty()){while(cur){
s.push(cur);
cur = cur->left;}
cur = s.top();if(cur->right == pre || cur->right ==nullptr){// printf(cur->data);
s.pop();
pre = cur;
cur =nullptr;}else{
pre = cur;
cur = cur->right;}}}