其他分享
首页 > 其他分享> > 简化版由前序遍历和中序遍历返回后序遍历

简化版由前序遍历和中序遍历返回后序遍历

作者:互联网

#include<iostream>
#include<cstring>
#include<string>
#include<stdio.h>
using namespace std;


void print(int n,char *x,char *y)
{
    if(n<=0)
    return;

    int lon= strchr (y,x[0])-y;
    print(lon,x+1,y);
    print(n-lon-1,x+lon+1,y+lon+1);

    cout << x[0] ;
}

int main()
{
    char x[30],y[30];
    while(cin >> x >> y)
    {
        int n=strlen(x);
        print(n,x,y);
        cout << endl; 
    }
}

 

标签:遍历,int,简化版,前序,char,print,include
来源: https://www.cnblogs.com/Abel-Gabriel/p/14728196.html