64,281
社区成员
发帖
与我相关
我的任务
分享
#include<iostream>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
if(n>9)
{
cout<<"输入错误,请重新输入"<<endl;
continue;
}
char order1[100],order2[100],stack[100];
cin>>order1>>order2;
int length,i,j;
for(i=0,j=0,length=0;i!=n;)
{
if(length==0||stack[length-1]!=order2[j])//这里...
{
stack[length++]=order1[i++];
}
for(;length>0&&stack[length-1]==order2[j];)
{
--length;
++j;
}
}
if(length==0)
{
cout<<"Yes."<<endl;
for(i=0,j=0,length=0;i!=n;)
{
for(;length==0||stack[length-1]!=order2[j];)
{
stack[length++]=order1[i++];
cout<<"in"<<endl;
}
for(;length>0&&stack[length-1]==order2[j];)
{
--length;
++j;
cout<<"out"<<endl;
}
}
}
else
cout<<"No."<<endl;
cout<<"FINISH"<<endl;
}
return 0;
}
#include<iostream>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
if(n>9)
{
cout<<"输入错误,请重新输入"<<endl;
continue;
}
char order1[100],order2[100],stack[100];
cin>>order1>>order2;
int length,i,j;
for(i=0,j=0,length=0;i!=n;)
{
for(;length==0||stack[length-1]!=order2[j];)//和这里... {
stack[length++]=order1[i++];
}
for(;length>0&&stack[length-1]==order2[j];)
{
--length;
++j;
}
}
if(length==0)
{
cout<<"Yes."<<endl;
for(i=0,j=0,length=0;i!=n;)
{
for(;length==0||stack[length-1]!=order2[j];)
{
stack[length++]=order1[i++];
cout<<"in"<<endl;
}
for(;length>0&&stack[length-1]==order2[j];)
{
--length;
++j;
cout<<"out"<<endl;
}
}
}
else
cout<<"No."<<endl;
cout<<"FINISH"<<endl;
}
return 0;
}