首页 > 其他 > 详细

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

时间:2021-05-03 22:18:48      阅读:30      评论:0      收藏:0      [点我收藏+]
#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; 
    }
}

 

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

原文:https://www.cnblogs.com/Abel-Gabriel/p/14728196.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!