#include<bits/stdc++.h>
using namespace std;
struct node{char pa,data,lc,rc;}a[10001];
int vis[201],root=-1;
int (xianxuint i){
printf("%c",i);
if(a[i].lc!=‘*‘)xianxu(a[i].lc);
if(a[i].rc!=‘*‘)xianxu(a[i].rc);
}
int main(){
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++){
char data;
cin>>data;
cin>>a[data].lc>>a[data].rc;
a[a[data].lc].pa=data;
a[a[data].rc].pa=data;
vis[data]=1;
}
for(int i=1;i<=122;i++)
if(a[i].lc!=0&&a[i].pa==0)root=i;
xianxu(root);
return0;
}
时间: 2024-11-05 21:39:37