国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

數(shù)據(jù)結(jié)構(gòu)上機(jī)測(cè)試4.1:二叉樹(shù)的遍歷與應(yīng)用1

2019-11-11 02:49:21
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

PRoblem Description

輸入二叉樹(shù)的先序遍歷序列和中序遍歷序列,輸出該二叉樹(shù)的后序遍歷序列。

Input

第一行輸入二叉樹(shù)的先序遍歷序列;第二行輸入二叉樹(shù)的中序遍歷序列。

Output

輸出該二叉樹(shù)的后序遍歷序列。

Example Input

ABDCEFBDAECF

Example Output

DBEFCA
 
#include<stdio.h>#include<string.h>#include<stdlib.h>typedef struct node{    char data;    struct node *lc,*rc;}bitree;bitree * create(int hlen,char qst[51],char hst[51]){    int i;    bitree * t;    if(hlen<=0)        return NULL;    t=(bitree *)malloc(sizeof(bitree));    t->data=qst[0];    for(i=0;i<hlen;i++)    {        if(hst[i]==qst[0])            break;    }    t->lc=create(i,qst+1,hst);    t->rc=create(hlen-i-1,qst+i+1,hst+i+1);    return t;}void postshow(bitree * tree){    bitree * t;    t=tree;    if(t)    {        postshow(t->lc);        postshow(t->rc);        printf("%c",t->data);    }}int main(){    int hlen;    char qst[51],hst[51];    bitree * tree;    scanf("%s%s",qst,hst);    hlen=strlen(hst);    tree=create(hlen,qst,hst);    postshow(tree);    printf("/n");    return 0;}
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 宁都县| 阳江市| 徐水县| 石台县| 瑞金市| 若尔盖县| 屯门区| 海门市| 营口市| 奉化市| 哈巴河县| 高陵县| 广饶县| 益阳市| 香港| 邯郸市| 白水县| 吉隆县| 黄大仙区| 绥中县| 黄冈市| 普定县| 苗栗市| 文水县| 新晃| 杭州市| 额济纳旗| 宁陵县| 台中县| 万宁市| 铁岭市| 大关县| 铁力市| 子长县| 蓬溪县| 鄂尔多斯市| 甘孜县| 高陵县| 常宁市| 佛山市| 砀山县|