Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
分享个递归的 0MS364B#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator