PersonalCorpus 版 (精华区)
36627 2002-09-24 17:03:23 Accepted
1004 C++ 00:00.00 384K Big Guava
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <math.h>
#include <ctype.h>
char s[1000],t[1000],st[1000],path[1000];
int ps,pt,pst;
void tryit(int dep)
{
if (t[pt]==0) {
for (int i=0;i<dep;i++) printf("%c ",path[i]);
printf("\n");
return;
}
if (s[ps]!=0) {
path[dep]='i';
st[pst++]=s[ps++];
tryit(dep+1);
pst--; ps--;
}
if ((pst!=0)&&(st[pst-1]==t[pt])) {
path[dep]='o';
pst--;
char ch=st[pst];
pt++;
tryit(dep+1);
st[pst]=ch;
pst++;
pt--;
}
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("c:\\0acm\\zju\\i1004","r",stdin);
freopen("c:\\0acm\\zju\\o1004","w",stdout);
#endif
while (gets(s)!=NULL) {
gets(t);
ps=pt=pst=0;
printf("[\n");
tryit(0);
printf("]\n");
}
return 0;
}
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.011毫秒