hdu 1022 wa 求解
#include<iostream>#include<string>#include<stack>#include<vector>usingnamespacestd;in...
#include<iostream>
#include<string>
#include<stack>
#include<vector>
using namespace std;
int main()
{
int n,m,i,j;
string in,out;
while (cin>>n>>in>>out)
{
stack <char> s;
vector <string> pr;
int sum=0;
i=j=0;
while(i<n)
{
s.push(in[i++]);
pr.push_back("in");
while(!s.empty())
{
if (s.top()==out[j]&&j<=n){j++;s.pop();pr.push_back("out");}
else break;
}
}
if (!s.empty()) {cout<<"No"<<endl;}
else {
cout<<"Yes"<<endl;
for (i=0;i<pr.size();i++)
cout<<pr[i]<<endl;
}
cout<<"FINISH"<<endl;
pr.clear();
for (i=0;i<s.size();i++)
s.pop();
}
return 0;
}
不要复制代码 求这个哪错了 展开
#include<string>
#include<stack>
#include<vector>
using namespace std;
int main()
{
int n,m,i,j;
string in,out;
while (cin>>n>>in>>out)
{
stack <char> s;
vector <string> pr;
int sum=0;
i=j=0;
while(i<n)
{
s.push(in[i++]);
pr.push_back("in");
while(!s.empty())
{
if (s.top()==out[j]&&j<=n){j++;s.pop();pr.push_back("out");}
else break;
}
}
if (!s.empty()) {cout<<"No"<<endl;}
else {
cout<<"Yes"<<endl;
for (i=0;i<pr.size();i++)
cout<<pr[i]<<endl;
}
cout<<"FINISH"<<endl;
pr.clear();
for (i=0;i<s.size();i++)
s.pop();
}
return 0;
}
不要复制代码 求这个哪错了 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询