简单题,模拟栈的操作。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 10000
int main()
{
int n,t1,t2,i,j,k;
char s1[N],s2[N][4],x[N],y[N];
while(scanf("%d%s%s",&n,x,y)!=EOF)
{
t1=-1;k=j=0;
for(i=0;x[i];i++)
{
s1[++t1]=x[i];
strcpy(s2[k++],"in");
if(s1[t1]==y[j])
{
while(y[j] && t1>=0 && y[j]==s1[t1])
{
t1--;
j++;
strcpy(s2[k++],"out");
}
}
}
if(t1!=-1) {
printf("No.\nFINISH\n");
}
else
{
printf("Yes.\n");
for(i=0;i<k;i++)
printf("%s\n",s2[i]);
printf("FINISH\n");
}
}
return 0;
}
本文来源于网络小筑 http://www.iwebtrados.com.cn/ , 原文地址:http://www.iwebtrados.com.cn/post/230.html