title

求先序遍历

#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
void beford(string in,string after){
	if(in.size()){
		char ch=after[after.size()-1];
		cout<<ch;
		int k=in.find(ch);
		beford(in.substr(0,k),after.substr(0,k));
		beford(in.substr(k+1),after.substr(k,in.size()-k-1));
	}
}
int main(){
	string inord,aftord;
	cin>>inord>>aftord;
	beford(inord,aftord);
	return 0;
}
posted @ 2018-09-10 01:07  Horrigue_JyowYang  阅读(74)  评论(0编辑  收藏  举报