• <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)  編輯 收藏 引用 所屬分類: 題目分類:數據結構
            国产精久久一区二区三区 | 久久久综合香蕉尹人综合网| 久久婷婷五月综合色99啪ak | 久久久久久国产精品无码下载| 69久久夜色精品国产69| 国产精品美女久久福利网站| 国产成人精品久久综合 | 久久综合给久久狠狠97色| 香蕉久久永久视频| yellow中文字幕久久网| 一极黄色视频久久网站| 亚洲精品视频久久久| 激情伊人五月天久久综合| 99久久成人国产精品免费| 久久久久亚洲AV无码专区网站 | 国产激情久久久久影院| 久久婷婷激情综合色综合俺也去 | 狠狠88综合久久久久综合网| 久久无码AV中文出轨人妻| 久久国产乱子精品免费女| 久久这里只有精品久久| 国产叼嘿久久精品久久| 午夜不卡久久精品无码免费| 日本强好片久久久久久AAA| 亚洲国产视频久久| 久久久午夜精品| 久久久久久无码国产精品中文字幕| 久久久久亚洲av毛片大| 秋霞久久国产精品电影院| 久久精品人人做人人爽97 | 久久亚洲综合色一区二区三区| 久久精品一区二区三区AV| 久久久久久国产精品无码下载| 久久国产免费观看精品| 人人狠狠综合久久88成人| 少妇久久久久久被弄高潮| 亚洲AV无码久久| 久久精品国产清自在天天线| 国产成人综合久久精品红| 欧美亚洲国产精品久久高清| 一97日本道伊人久久综合影院|