1 solutions

  • 0
    @ 2025-12-10 15:45:04
    #include <bits/stdc++.h>
    using namespace std;
    struct node{
        char zhi;
        int left,right;
    }no[27];
    void qian(int st){
        if(st==0) return ;
        cout <<no[st].zhi;
        qian(no[st].left);
        qian(no[st].right);
    }
    void zhong(int st){
        if(st==0) return ;
        zhong(no[st].left);
        cout <<no[st].zhi;
        zhong(no[st].right);
    }
    void hou(int st){
        if(st==0) return ;
      
        hou(no[st].left);
        hou(no[st].right);
        cout <<no[st].zhi;
    }
    int main() {
    int n;
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>no[i].zhi>>no[i].left>>no[i].right;
        }
        qian(1);
        cout<<endl;
        zhong(1);
        cout<<endl;
        hou(1);
        return 0;
    }
    
    
    • 1

    Information

    ID
    110
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    10
    Tags
    # Submissions
    2
    Accepted
    1
    Uploaded By