• <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>

            我住包子山

            this->blog.MoveTo("blog.baozishan.in")

            zju 1004 Anagrams by Stack 我的很不規(guī)范的程序

            #include <iostream>
            #include <string>
            using namespace std;

            string stack,requare,start,newStr;
            string table;
            int num=0,i=0;
            void check(string& start,string& stack);
            void print(){
            ? if(newStr==requare)
            ? cout<<table<<endl;
            }
            void pushStack(char item,string& start,string& stack){
            ?table+='i';
            ?stack+=item;
            ?check(start,stack);

            }
            void popStack(string& start,string& stack){
            ?table+='o';
            ?newStr+=stack[stack.size()-1];
            ?stack.erase(stack.size()-1);
            ?check(start,stack);
            }
            void delPush(){
            ? table.erase(table.size()-1);
            ? stack.erase(stack.size()-1);

            }
            void delPop(){
            ? stack+=newStr[newStr.size()-1];
            ? table.erase(table.size()-1);
            ? newStr.erase(newStr.size()-1);
            }

            void check(string& start,string& stack){
            ?if (num==start.size()*2) {
            ??print();?
            ??return;
            ?}
            ?
            ??
            ??? if((newStr.size()+stack.size())!=start.size()){
            ??? num++;
            ??? pushStack(start[i++],start,stack);
            ??? delPush();
            ??? num--;
            ??? i--;
            ??? }
            ??? if(stack.empty()&&i<start.size()) return;
            ??? num++;
            ??? popStack(start,stack);
            ??? delPop();
            ??? num--;
            ?
            ?
            }


            int main(){


            ?cin>>start>>requare;

            ?check(start,stack);
            ?return 0;
            }

            ?

            很不規(guī)范的地柜,還有好多個(gè)清理狀態(tài)的函數(shù)。。。
            什么時(shí)候才能改進(jìn)阿!!!!!!!!

            posted on 2006-09-04 11:39 Gohan 閱讀(763) 評(píng)論(2)  編輯 收藏 引用 所屬分類: C++

            Feedback

            # re: zju 1004 Anagrams by Stack 我的很不規(guī)范的程序 2007-07-03 16:22 niny

            // 1004_Anagrams_By_Stack.cpp : 定義控制臺(tái)應(yīng)用程序的入口點(diǎn)。
            //

            #include "stdafx.h"
            #include <stack>
            #include <vector>
            #include <iostream>
            #include <string>
            using namespace std;

            vector<char> src,drt;

            void dfs(vector<char>::iterator sp,vector<char>::iterator dp,vector<char> op,stack<char> s)
            {
            if(dp==drt.end()){
            vector<char>::iterator p;
            for(p=op.begin();p!=op.end();p++)
            cout<<*p<<' ';
            cout<<endl;
            return;
            }

            if(sp!=src.end()){
            s.push(*sp);
            op.push_back('i');
            dfs(sp+1,dp,op,s);
            op.pop_back();
            s.pop();
            }

            if(!s.empty()&&s.top()==(*dp)){
            s.pop();
            op.push_back('o');
            dfs(sp,dp+1,op,s);
            op.pop_back();
            s.push(*dp);
            }
            }


            int _tmain(int argc, _TCHAR* argv[])
            {
            stack<char> s;
            vector<char> op;
            string st;
            bool sord=true;
            while(cin>>st){
            if(sord){
            for(int i=0;i!=st.size();i++)
            src.push_back(st[i]);
            }
            else{
            for(int i=0;i!=st.size();i++)
            drt.push_back(st[i]);
            }
            sord=!sord;
            if(sord){
            cout<<"["<<endl;
            dfs(src.begin(),drt.begin(),op,s);
            cout<<"]"<<endl;
            op.clear();
            while(!s.empty())
            s.pop();
            src.clear();
            drt.clear();
            }
            }
            return 0;
            }

              回復(fù)  更多評(píng)論   

            # re: zju 1004 Anagrams by Stack 我的很不規(guī)范的程序 2007-07-09 22:59 Gohan

            dfs寫的很美觀啊,多謝回復(fù):)  回復(fù)  更多評(píng)論   

            伊人久久大香线蕉综合网站| 一本色道久久88综合日韩精品| 久久人人爽人人爽人人片av高请| 国产精品久久久香蕉| 欧美亚洲色综久久精品国产| 国产成人精品白浆久久69| 办公室久久精品| 久久免费看黄a级毛片| 91精品国产91久久久久福利| 久久精品成人欧美大片| 欧美牲交A欧牲交aⅴ久久| 久久亚洲欧洲国产综合| 97超级碰碰碰久久久久| 久久99国产精品久久99小说| 女人香蕉久久**毛片精品| 亚洲乱码日产精品a级毛片久久| 久久A级毛片免费观看| 久久久亚洲裙底偷窥综合| 国产精品VIDEOSSEX久久发布| 麻豆成人久久精品二区三区免费 | 免费观看久久精彩视频| 久久精品亚洲AV久久久无码| 国产高清国内精品福利99久久| 亚洲AV无码久久| 无码任你躁久久久久久老妇| 91精品免费久久久久久久久| 久久精品国产亚洲AV嫖农村妇女| 久久综合狠狠综合久久97色| 久久香蕉国产线看观看乱码| 蜜臀av性久久久久蜜臀aⅴ麻豆 | 精品国产青草久久久久福利| 久久高潮一级毛片免费| 久久国产成人| 久久天天躁狠狠躁夜夜不卡| 久久九九久精品国产| 国内精品久久久久久久久电影网 | 久久久久久久久久久免费精品| 97超级碰碰碰碰久久久久| 91精品观看91久久久久久| 国产视频久久| 久久影院亚洲一区|