problem
solution
codes
#include<iostream>
using namespace std;
const int maxn = 110;
int tree[maxn][2];
void dfs1(int now){
cout<<now<<" ";
if(tree[now][0])dfs1(tree[now][0]);
if(tree[now][1])dfs1(tree[now][1]);
}
void dfs2(int now){
if(tree[now][0])dfs2(tree[now][0]);
cout<<now<<" ";
if(tree[now][1])dfs2(tree[now][1]);
}
void dfs3(int now){
if(tree[now][0])dfs3(tree[now][0]);
if(tree[now][1])dfs3(tree[now][1]);
cout<<now<<" ";
}
int main(){
int n; cin>>n;
for(int i = 1; i <= n; i++)
cin>>tree[i][0]>>tree[i][1];
dfs1(1); cout<<"\n";
dfs2(1); cout<<"\n";
dfs3(1); cout<<"\n";
return 0;
}