• <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)  編輯 收藏 引用 所屬分類: 題目分類:數據結構
            亚洲人成伊人成综合网久久久| 热re99久久6国产精品免费| 丁香狠狠色婷婷久久综合| 色成年激情久久综合| 久久亚洲AV无码西西人体| 久久亚洲AV成人无码电影| 97久久精品人人澡人人爽| 久久久久久久久久久精品尤物| 久久99精品久久久久久久不卡| 国产叼嘿久久精品久久| 亚洲精品美女久久777777| 久久本道久久综合伊人| 精品久久人妻av中文字幕| 色天使久久综合网天天| 久久夜色精品国产亚洲| 一本色道久久88精品综合| 久久亚洲高清综合| 欧美精品一区二区精品久久| 影音先锋女人AV鲁色资源网久久| 久久91这里精品国产2020| 狠狠干狠狠久久| 久久精品99久久香蕉国产色戒 | 久久天天躁夜夜躁狠狠躁2022| 色偷偷88888欧美精品久久久| 久久精品国产99久久久香蕉| 精品久久久久久久| 97久久久久人妻精品专区| 伊人久久大香线蕉亚洲五月天| 日韩欧美亚洲综合久久影院Ds| 久久国产综合精品五月天| 久久er国产精品免费观看2| 久久99精品国产麻豆| 久久综合给久久狠狠97色| 亚洲国产精品无码久久SM| 国产精品亚洲综合久久 | 国产日韩欧美久久| 91精品国产91久久久久久| 国产精品成人精品久久久| 91精品国产高清久久久久久国产嫩草| 久久丫精品国产亚洲av不卡| 久久精品www人人爽人人|