• <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 閱讀(299) 評論(0)  編輯 收藏 引用 所屬分類: 題目分類:數據結構
            www性久久久com| 国产精品永久久久久久久久久| 亚洲精品国产自在久久| 久久久精品人妻一区二区三区蜜桃| 亚洲AV伊人久久青青草原| 无码国产69精品久久久久网站| 久久久久99精品成人片欧美| 一本大道加勒比久久综合| 欧美午夜A∨大片久久| 国产精品久久久久久吹潮| 欧美久久久久久精选9999| 久久久噜噜噜久久熟女AA片| 久久露脸国产精品| 2020最新久久久视精品爱 | 国产成人久久777777| 久久精品亚洲一区二区三区浴池| 日韩十八禁一区二区久久| 久久99精品国产一区二区三区| 久久精品国产亚洲AV久| 久久久亚洲欧洲日产国码是AV | 久久青草国产精品一区| 国产一区二区三区久久精品| 丰满少妇人妻久久久久久| 嫩草影院久久99| 久久久久亚洲AV成人网| 久久久久久av无码免费看大片| 久久影视国产亚洲| 久久九九全国免费| 久久久久精品国产亚洲AV无码| 久久无码人妻一区二区三区午夜| av色综合久久天堂av色综合在 | 91精品免费久久久久久久久| 欧美性大战久久久久久| 国产精品久久久久jk制服| 久久久久亚洲AV无码专区桃色| 18岁日韩内射颜射午夜久久成人| 91久久婷婷国产综合精品青草| 色狠狠久久综合网| 精品人妻伦九区久久AAA片69| 久久精品九九亚洲精品| 99精品国产综合久久久久五月天|