Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

如果你懂得,可否停下来告诉俺这是为什么,怪异的结果

Posted by 53150 at 2011-08-08 22:16:54 on Problem 2255
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator