| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
如果你懂得,可否停下来告诉俺这是为什么,怪异的结果
#include<iostream>
#include<string>
#include<stack>
using namespace std;
void after(stack<char> &s,string a,string b)
{
int la=a.size(),lb=b.size();
if(la==0)return;
s.push(a[0]);
int pos=b.find(a[0]);
string a1,b1,a2,b2;
a2=a.assign(a.begin()+1+pos,a.begin()+la);
b2=b.assign(b.begin()+pos+1,b.begin()+lb);
a1=a.assign(a.begin()+1,a.begin()+1+pos);
b1=b.assign(b.begin(),b.begin()+pos);
after(s,a2,b2);
after(s,a1,b1);
}
int main()
{
string a, b;
stack<char> s;
while(cin>>a>>b)
{
after(s,a,b);
while(!s.empty())
{
cout<<s.top();
s.pop();
}
cout<<endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator