• <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)典的題目吧,我把代碼貼上來(lái)了。
            考察隊(duì)列和棧的基本操作,記得《算法藝術(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) 評(píng)論(0)  編輯 收藏 引用 所屬分類: 題目分類:數(shù)據(jù)結(jié)構(gòu)
            国产精品一久久香蕉产线看| 久久久噜噜噜久久| 色欲av伊人久久大香线蕉影院| 国内精品人妻无码久久久影院导航 | 精品国产日韩久久亚洲| 婷婷综合久久中文字幕蜜桃三电影| 久久人做人爽一区二区三区| 久久精品国产99久久久| 久久精品国产亚洲Aⅴ香蕉| 亚洲成色WWW久久网站| 99国内精品久久久久久久| 亚洲国产另类久久久精品| 亚洲国产成人久久精品影视| 国产成人精品久久| 久久久久久国产a免费观看不卡| 久久久久人妻一区二区三区vr| 91精品免费久久久久久久久| 久久永久免费人妻精品下载| 久久久久亚洲?V成人无码| 久久国产精品久久| 久久丫精品国产亚洲av| 久久毛片一区二区| 久久毛片免费看一区二区三区| 久久精品国产一区二区三区日韩| 亚洲国产另类久久久精品小说 | 久久久久人妻一区精品性色av| 久久免费国产精品| 精品久久久久久久久久久久久久久 | 国产精品一区二区久久精品涩爱| 国产69精品久久久久99| 国产日产久久高清欧美一区| 久久婷婷国产综合精品| 日韩AV无码久久一区二区| 无码久久精品国产亚洲Av影片| 久久人人爽人人爽人人爽| 久久亚洲精品成人无码网站| 亚洲精品久久久www| 亚洲成av人片不卡无码久久| 国产69精品久久久久APP下载| 狠狠色丁香久久婷婷综合图片| 精品多毛少妇人妻AV免费久久 |