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

HDUOJ Train Problem I

2015-08-02 09:38 281 查看

#include<stdio.h>

#include<string.h>

#include<stack>

using namespace std;

stack<char> str;

char s1[9],s2[9];

int main()

{

int n;

str.push('#');

while(~scanf("%d %s %s",&n,s1,s2))

{

while(str.top()!='#')

str.pop();

int l=0,i;

for(i=0;i<n;i++)

{

str.push(s1[i]);

if(str.top()==s2[l])

{

while(str.top()==s2[l])

{

str.pop();

l++;

}

}

}

if(str.top()=='#')

{

printf("Yes.\n");

l=0;

for(i=0;i<n;i++)

{

if(str.top()!=s2[l])

{

str.push(s1[i]);

printf("in\n");

if(str.top()==s2[l])

{

while(str.top()==s2[l])

{

str.pop();

printf("out\n");

l++;

}

}

}

}

printf("FINISH\n");

}

else printf("No.\nFINISH\n");

}

return 0;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: