题解 | #二叉树遍历#
二叉树遍历
https://www.nowcoder.com/practice/4b91205483694f449f94c179883c1fef
#include <iostream> using namespace std; string s; int k = 0; void dfs(){ if(s[k] == '#'){ k ++; return; } char root = s[k ++]; dfs(); cout<<root<<' '; dfs(); } int main(){ while(cin>>s){ dfs(); cout<<endl; } return 0; }
好难 啊啊啊啊