30分,a了3、4、5
查看原帖
30分,a了3、4、5
1189340
aishiteru_mitsu_ha楼主2024/4/2 18:29
#include<bits/stdc++.h>
using namespace std;
struct node{
    char date='0';
    int l,r;
}tree[114514];
int n;
char left,right;
void fdfs(int x);
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        char a,b,c;
        cin>>a>>b>>c;
        tree[a-'a'+1].date=a;
        if(b!='*') tree[a-'a'+1].l=b-'a'+1;
        else tree[a-'a'+1].l=0;
        if(c!='*') tree[a-'a'+1].r=c-'a'+1;
        else tree[a-'a'+1].r=0;
    }
    fdfs(1);
    return 0;
}
void fdfs(int x){
    if(tree[x].date!='0'){
        cout<<tree[x].date;
        fdfs(tree[x].l);
        fdfs(tree[x].r);
    }
}
2024/4/2 18:29
加载中...