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

            99精品久久久久久久婷婷| 久久亚洲精品成人AV| 久久精品成人免费观看97| A级毛片无码久久精品免费| 99久久精品久久久久久清纯| 久久91精品国产91| 日韩欧美亚洲综合久久影院d3| 亚洲国产香蕉人人爽成AV片久久| 午夜天堂av天堂久久久| 久久精品国产亚洲5555| 人妻精品久久无码专区精东影业 | 伊人热人久久中文字幕| 久久综合视频网站| 久久综合综合久久狠狠狠97色88| 中文成人久久久久影院免费观看| AAA级久久久精品无码片| 久久婷婷五月综合97色直播| 国产高潮久久免费观看| 国内精品人妻无码久久久影院 | 日韩精品久久久久久| 日韩人妻无码精品久久久不卡 | 久久电影网一区| 久久久久久亚洲AV无码专区| 少妇被又大又粗又爽毛片久久黑人 | 久久久久亚洲av无码专区导航| 久久人人爽人人爽人人片AV东京热| 狠狠狠色丁香婷婷综合久久俺| 久久亚洲私人国产精品vA| 久久AV无码精品人妻糸列| 国产毛片欧美毛片久久久| 久久AV无码精品人妻糸列| 国产A级毛片久久久精品毛片| 亚洲精品成人网久久久久久| 欧美一区二区久久精品| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 久久亚洲国产精品123区| 国产午夜精品久久久久九九电影| 国产成人精品久久亚洲高清不卡 | 青青草原综合久久| 国产精品无码久久四虎| 久久久久亚洲精品男人的天堂|