• <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
            很經典的題目吧,我把代碼貼上來了。
            考察隊列和棧的基本操作,記得《算法藝術》上有講解。
            以下是我的代碼:
            #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)  編輯 收藏 引用 所屬分類: 題目分類:數據結構
            精品综合久久久久久88小说 | 97久久精品午夜一区二区| 亚洲女久久久噜噜噜熟女| 亚洲精品乱码久久久久久中文字幕 | 久久国产免费| 91视频国产91久久久| 久久精品男人影院| 久久久久久夜精品精品免费啦| 久久国产一区二区| 色偷偷88欧美精品久久久| 久久久无码精品亚洲日韩按摩 | 国产精品18久久久久久vr| 久久久久久噜噜精品免费直播| 久久精品极品盛宴观看| 97久久精品人人澡人人爽| 漂亮人妻被黑人久久精品| 久久精品免费全国观看国产| 久久免费线看线看| 国产精品久久国产精麻豆99网站| 精品久久久无码中文字幕| 久久99国产精品尤物| 国产精品免费看久久久| 天堂无码久久综合东京热| 国产精品99久久久久久猫咪| 中文字幕久久欲求不满| 人妻少妇久久中文字幕| 亚洲欧美另类日本久久国产真实乱对白| 久久露脸国产精品| 久久嫩草影院免费看夜色| 久久精品成人免费看| 999久久久无码国产精品| 国产成人久久精品一区二区三区| 亚洲国产成人精品无码久久久久久综合 | 久久久久国产精品熟女影院| 99久久免费国产精品特黄| 久久无码AV中文出轨人妻| 99国内精品久久久久久久| 久久精品国产久精国产思思| 久久久女人与动物群交毛片| 久久综合狠狠综合久久| 97久久精品午夜一区二区|