• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            心如止水
            Je n'ai pas le temps
            posts - 400,comments - 130,trackbacks - 0
            很經(jīng)典的題目吧,我把代碼貼上來了。
            考察隊列和棧的基本操作,記得《算法藝術(shù)》上有講解。
            以下是我的代碼:
            #include<iostream>
            #include
            <string>
            #include
            <queue>
            #include
            <stack>
            #include
            <cstdio>
            using namespace std;

            int main()
            {
                
            /*
                freopen("data.in","r",stdin);
                freopen("data.out","w",stdout);
                //
            */
                
                
            int n;
                
            while(cin>>n)
                {
                    
            string order1,order2;
                    cin
            >>order1>>order2;
                    queue
            <char> q;
                    
            for(int i=0;i<order1.size();i++)
                        q.push(order1[i]);
                    stack
            <char> s;
                    
            int pos(0),ans[100]={0},ans_len(0);
                    
            bool success=true;
                    
            while(!q.empty())
                    {
                        
            if(!s.empty()&&s.top()==order2[pos])
                        {
                            s.pop();
                            pos
            ++;
                            ans[
            ++ans_len]=0;
                        }
                        
            else
                        {
                            s.push(q.front());
                            q.pop();
                            ans[
            ++ans_len]=1;
                        }
                    }
                    
            while(!s.empty())
                    {
                        
            if(s.top()==order2[pos])
                        {
                            s.pop();
                            pos
            ++;
                            ans[
            ++ans_len]=0;
                        }
                        
            else
                        {
                            success
            =false;
                            
            break;
                        }
                    }
                    
                    
            if(success)
                    {
                        cout
            <<"Yes."<<endl;
                        
            for(int i=1;i<=ans_len;i++)
                            
            if(ans[i]==1)
                                cout
            <<"in"<<endl;
                            
            else cout<<"out"<<endl;
                    }
                    
            else cout<<"No."<<endl;
                    cout
            <<"FINISH"<<endl;
                }
                
            return 0;
            }
            posted on 2011-02-23 09:30 lee1r 閱讀(301) 評論(0)  編輯 收藏 引用 所屬分類: 題目分類:數(shù)據(jù)結(jié)構(gòu)
            精品久久久久久99人妻| 精品久久久久久无码人妻热 | 久久综合九色综合精品| 99久久国产综合精品麻豆| 日本道色综合久久影院| 精品免费久久久久国产一区| 久久AⅤ人妻少妇嫩草影院| 国内精品久久久久久久久电影网| 国产精品9999久久久久| 色悠久久久久久久综合网| 国产产无码乱码精品久久鸭| 久久av高潮av无码av喷吹| 亚洲国产美女精品久久久久∴| 久久久久99精品成人片| 久久九九青青国产精品| 久久综合色老色| 久久久久亚洲精品中文字幕 | 婷婷伊人久久大香线蕉AV| 99久久亚洲综合精品成人| 久久青青草原精品国产软件| 久久精品欧美日韩精品| 久久久久精品国产亚洲AV无码| 久久青青草原精品国产不卡| 久久久久成人精品无码中文字幕| 久久综合五月丁香久久激情| 久久亚洲综合色一区二区三区| 亚洲精品无码成人片久久| 99久久这里只精品国产免费| 久久久久亚洲AV无码去区首| 2021少妇久久久久久久久久| 午夜人妻久久久久久久久| 久久99精品国产麻豆宅宅| 久久久这里只有精品加勒比| 久久综合精品国产一区二区三区| 久久综合丝袜日本网| 久久亚洲国产精品一区二区| 99久久精品午夜一区二区| 东京热TOKYO综合久久精品| 久久久亚洲欧洲日产国码二区| 久久综合给合久久国产免费| 久久96国产精品久久久|