MYCGOOD


私信TA

用户名:dotcpp0729782

访问量:106

签 名:

等  级
排  名 14709
经  验 816
参赛次数 0
文章发表 8
年  龄 0
在职情况 学生
学  校 太原理工大学
专  业

  自我简介:


解题思路:

注意事项:

参考代码:

#include<iostream>
using namespace std;
string s1,s2;
void dfs(int l1,int r1,int l2,int r2)
{
	if(l1>r1) return;
	char temp=s1[l1];
	int pos=0;
	for(int i=0;i<s2.size();i++)
	{
		if(s2[i]==temp) 
		{
		   pos=i;
		   break;
		}
	}
	int len=pos-l2;
	dfs(l1+1,l1+len,l2,len-1);
	dfs(l1+len+1,r1,l2+len+1,r2);
	cout<<temp;
}
int main()
{
	while(getline(cin,s1))
	{
	  getline(cin,s2);
	int len=s1.size()-1; 
	dfs(0,len,0,len);
	cout<<endl;
    }
	return 0;
}


 

0.0分

1 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区