Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

分享个递归的 0MS364B

Posted by comzyh at 2013-06-06 22:06:43 on Problem 2255
#include <cstdio>
#include <cstring>
char F[100],M[100];
int dfs(int f,int b,int e)
{
	int i,j;
	for (i=b;i<=e && M[i]!=F[f];i++);
	if (b!=i)
		f=dfs(f+1,b,i-1);
	if (i!=e)
		f=dfs(f+1,i+1,e);
	printf("%c",M[i]);
	return f;//读到F最后一个元素的下标
}
int main()
{
	while (scanf("%s%s",&F,&M)!=EOF)
	{
		dfs(0,0,strlen(F)-1);
		printf("\n");
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator