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

首頁 > 學院 > 開發設計 > 正文

sdutacm-數據結構上機測試4.1:二叉樹的遍歷與應用1

2019-11-06 06:48:11
字體:
來源:轉載
供稿:網友

數據結構上機測試4.1:二叉樹的遍歷與應用1

TimeLimit: 1000MS Memory Limit: 65536KB

SubmitStatistic

PRoblem Description

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

Input

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

Output

輸出該二叉樹的后序遍歷序列。

Example Input

ABDCEF

BDAECF

Example Output

DBEFCA

Hint

Author

#include<string.h>#include<stdio.h>#include<stdlib.h>#include<algorithm>#include<queue>#include<iostream>using namespace std;typedef struct node{   char data;   struct node*l;   struct node*r;}tree;void huifu(char *xian,char *zhong,int len){  if(len==0)  return ;  tree *p = new tree;  p->data = *xian;  int i = 0;  for(;i<len;i++)  if(zhong[i]==*xian)  {     break;  }  huifu(xian+1,zhong,i);  huifu(xian+i+1,zhong+i+1,len-i-1);  cout<<p->data;  return ;}int main(){   char xian[102],zhong[102];   int i,len;   scanf("%s%s",xian,zhong);   len = strlen(xian);   huifu(xian,zhong,len);   cout<<endl;}/***************************************************User name: jk160505徐紅博Result: AcceptedTake time: 0msTake Memory: 152KBSubmit time: 2017-02-07 15:04:24****************************************************/


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 宜兰县| 青州市| 株洲县| 遂溪县| 汽车| 哈密市| 佛冈县| 阳江市| 凤凰县| 新源县| 额尔古纳市| 哈尔滨市| 垦利县| 东方市| 渑池县| 峨眉山市| 西乌珠穆沁旗| 望谟县| 江都市| 林周县| 济宁市| 格尔木市| 丹江口市| 栖霞市| 惠来县| 张掖市| 河曲县| 阳谷县| 花莲县| 将乐县| 浦县| 海伦市| 荔波县| 石屏县| 防城港市| 当涂县| 老河口市| 耒阳市| 南阳市| 茌平县| 兴城市|