您的位置:首页 > 大数据 > 人工智能

Train Problem I

2009-10-11 20:15 176 查看
简单题,模拟栈的操作。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 10000
int main()
{
int n,t1,t2,i,j,k;
char s1
,s2
[4],x
,y
;
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息