lson 和 rson 是char
在10和11行为什么判断lson和rson>0呢
by kzpe626 @ 2023-11-13 22:02:16
还有第9行Int类型要改为char
by kzpe626 @ 2023-11-13 22:10:41
```cpp
#include <bits/stdc++.h>
using namespace std;
char lson[30],rson[30];
int n;
void dfs(char u)
{
if(u=='*') return;
cout<<u;
int a=u-'a'+1;
if(lson[a]!='*') dfs(lson[a]);
if(rson[a]!='*') dfs(rson[a]);
return;
}
signed main()
{
cin>>n;
int first;
bool b=true;
for(int i=1;i<=n;i++){
char c;
cin>>c;
if(b) first=c,b=false;
cin>>lson[c-'a'+1]>>rson[c-'a'+1];//将father与son的关系改了一下
}
dfs(first);//这里只用到第一个father,所以只用一个变量来存
return 0;
}
```
~~直接上代码~~
by kzpe626 @ 2023-11-13 22:13:02