foj_1532
来源:互联网 发布:unity3d海底场景demo 编辑:程序博客网 时间:2024/05/16 13:04
又是栈的问题
#include <iostream>#include <stack>#include <memory.h>#include <string.h>using namespace std;char s1[18],s2[18]; int step[34]; char s[34];int n;void dfs(int top,int m,int p1,int k){ int i; while(1) { if(s[top]==s2[k]&&top>-1) { if(s1[p1]!='\0') { s[top+1]=s1[p1];step[m]=1; } dfs(top+1,m+1,p1+1,k); top--; k++; step[m++]=0; } else { if(s1[p1]!='\0') { s[++top]=s1[p1++];step[m++]=1; } else { if(top==-1&&s2[k]=='\0') { for(i=0;i<m;i++) { cout<<step[i]; } cout<<endl;} return ;} } }}int main(){ while(~scanf("%s",s1)) { scanf("%s",s2); n=5; memset(step,0,sizeof(step));step[0]=1; s[0]=s1[0]; if(strlen(s1)!=strlen(s2))continue; dfs(0,1,1,0); } return 0;}
- foj_1532
- 嵌入式软件工程师经典笔试题
- 64-bit Windows Error: 61: Unknown error
- js中的异常处理try...catch使用介绍
- Android 获取屏幕的信息和button布局的一些笔记
- AutoCAD二次开发之视图操作(3)指定视图大小和中心点来设置视图
- foj_1532
- IOS私有API的了解
- delphi从dll中调用图片资源
- NSBundle介绍
- 黑马程序员------网络编程(No.1)(网络编程概述、UDP)
- 常用Android对话框的封装
- trim&option的Click
- 浏览器内核分类
- 黑马程序员java 图片添加水印