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

            The Fourth Dimension Space

            枯葉北風(fēng)寒,忽然年以殘,念往昔,語默心酸。二十光陰無一物,韶光賤,寐難安; 不畏形影單,道途阻且慢,哪曲折,如渡飛湍。斬浪劈波酬壯志,同把酒,共言歡! -如夢令

            #

            動態(tài)鏈表式堆棧 by abilitytao

            //template_by_abilitytao_ACM
            //many thanks to Mr Zhang Hong and Yu Ligong

            #include 
            <algorithm>
            #include
            <cstdio>
            #include
            <cmath>
            #include
            <cstdlib>
            #include
            <iostream>
            #include
            <cstdio>
            using namespace std;
            struct node {
                
            int data;
                node 
            *next;
            }
            ;

            class mystack 
            {
            private:
                node
            * ptop;//定義棧頂指針
                int lenth;//定義堆棧的動態(tài)容量
            public:
                mystack();
            //重載默認(rèn)構(gòu)造函數(shù)
                int push(int num);//壓棧操作
                int pop();//退棧操作
                int top();//返回棧頂元素
                int size();//返回堆棧的實際容量
                bool empty();
                
            bool full();
            }
            ;

            mystack::mystack()
            {

                ptop
            =NULL;
                lenth
            =0;
            }



            int mystack::push(int num)//操作成功,返回1;
            {

                node 
            *p=new node;
                p
            ->data=num;
                p
            ->next=ptop;
                ptop
            =p;//由于鏈表式堆棧沒有容量上線,故返回值為1;
                lenth++;
                
            return 1;
                
            return 0;
            }


            int mystack::pop()//堆棧為空返回0,操作成功返回所需要的整數(shù);
            {
                
            if(ptop==NULL)
                    
            return 0;
                
            int result;
                result
            =ptop->data;
                node 
            *p=ptop;
                ptop
            =p->next;
                delete p;
                lenth
            --;
                
            return result;
            }


            int mystack::top()
            {
                
            if(ptop==NULL)
                    
            return 0;
                
            return ptop->data;
            }



            int mystack::size()
            {
                
            return lenth;
            }


            bool mystack::empty()
            {

                
            if (ptop==NULL)
                    
            return true;
                
            else
                    
            return false;
            }


            bool mystack::full()
            {

                
            return false;//僅僅為了提高模板的健壯性
            }







            //////////////////////////////////////////////////////////////////////////test data////////////////////////////////////////////////////////////////////////////
            int main ()
            {

                mystack test;
                test.push(
            1);
                test.push(
            2);
                test.push(
            3);
                test.push(
            4);
                test.push(
            5);
                test.push(
            6);
                test.push(
            7);
                
            int a=test.size();
                a
            =test.top();
                a
            =test.pop();
                a
            =test.top();
                a
            =test.pop();
                a
            =test.top();
                a
            =test.pop();
                a
            =test.top();
                a
            =test.pop();
                a
            =test.pop();
                a
            =test.pop();
                a
            =test.top();
                a
            =test.pop();
                a
            =test.pop();
                a
            =test.top();
                a
            =test.empty();
            }

            posted @ 2009-03-02 21:48 abilitytao 閱讀(1089) | 評論 (3)編輯 收藏

            動態(tài)循環(huán)隊列模板類——鏈表實現(xiàn)

             

            //template_by_abilitytao_ACM
            //Begin_template_myqueue
            //這是一個非常高效的循環(huán)鏈表隊列
            #include<iostream>
            #include
            <cmath>
            #include
            <algorithm>
            #include
            <cstring>
            #include
            <cstdio>
            using namespace std;

            struct node {
                
            int data;
                node
            * next;
            }
            ;

            class myqueue
            {
            private:
                node 
            *prear;
                
            int lenth;
            public:
                myqueue();
                
            int push(int num);
                
            int pop();
                
            int front();
                
            int rear();
                
            int len();
                
            bool empty();
                
            bool full();
                
            }
            ;


            myqueue::myqueue()
            {

                prear
            =new node;
                prear
            ->data=0x7fffffff;
                prear
            ->next=prear;
                lenth
            =0;
            }



            int myqueue::push(int num)//入隊成功返回1,否則返回0 。問:(返回0有可能嗎?如果內(nèi)存不夠系統(tǒng)內(nèi)部有 返回值嗎,猜:返回null?)
            {
                
            {
                    node 
            *p=new node;
                    p
            ->data=num;
                    p
            ->next=prear->next;
                    prear
            ->next=p;
                    prear
            =p;
                    lenth
            ++;
                    
            return 1;
                }

                
            return 0;
            }


            int myqueue::pop()//如果出隊成功返回1,勾著否則返回0;
            {
                
            if(prear->next==prear)
                    
            return 0;
                node 
            *p=prear->next;
                node 
            *q=prear->next->next;
                p
            ->next=q->next;
                delete q;
                
            if(p=p->next)
                    prear
            =p;
                
            --lenth;
            }


            int myqueue::front()//隊列為空返回0,否則返回隊首元素的值
            {

                
            if(prear->next==prear)
                    
            return 0;
                node
            *p=prear->next->next;
                
            return p->data;

            }


            int myqueue::rear()//隊列為空返回值為0,否則返回隊尾元素的值
            {
                
            if(prear->next==prear)
                    
            return 0;
                
            return prear->data;
            }


            int myqueue::len()
            {
                
            return lenth;
            }


            bool myqueue::empty()
            {

                
            if(prear->next==prear)
                    
            return true;
                
            else
                    
            return false;
            }


            bool myqueue::full()//為了提高本模板的兼容性,故提供此函數(shù),其實函數(shù)的返回值永遠(yuǎn)不可能為1;
            {
                
            return false;
            }

            //endtemplate_by_abilitytao_ACM

            ////////////////////////////////////////////////////////////////////下面是測試數(shù)據(jù)////////////////////////////////////////////////////////////////////////////
            int main ()
            {

                myqueue test;
                
            int a=test.len();
                
            bool b=test.empty();
                test.push(
            1);
                test.push(
            2);
                a
            =test.front();
                a
            =test.rear();
                a
            =test.len();
                b
            =test.empty();
                b
            =test.full();
                a
            =test.pop();
                a
            =test.front();
                a
            =test.rear();
                a
            =test.pop();
                a
            =test.front();
                a
            =test.rear();

            }


            posted @ 2009-03-02 21:00 abilitytao 閱讀(1635) | 評論 (0)編輯 收藏

            A*算法詳解——by Sunway

                 摘要: 寫這篇文章的初衷是應(yīng)一個網(wǎng)友的要求,當(dāng)然我也發(fā)現(xiàn)現(xiàn)在有關(guān)人工智能的中文站點實在太少,我在這里拋磚引玉,希望大家都來熱心的參與。還是說正題,我先拿A*算法開刀,是因為A*在游戲中有它很典型的用法,是人工智能在游戲中的代表。A*算法在人工智能中是一種典型的啟發(fā)式搜索算法,為了說清楚A*算法,我看還是先說說何謂啟發(fā)式算法。1、何謂啟發(fā)式搜索算法  在說它之前先提提狀態(tài)空間搜索。狀態(tài)空間搜索,如果按專業(yè)點...  閱讀全文

            posted @ 2009-03-01 21:34 abilitytao 閱讀(6448) | 評論 (9)編輯 收藏

            ACRUSH-樓天成 百度之星答題源碼

                 摘要: 初賽一 #include <stdio.h> #include <stdlib.h> #include <string.h> #define _MAXL 2000000 void GetN(char *s,long long &am...  閱讀全文

            posted @ 2009-03-01 20:51 abilitytao 閱讀(6523) | 評論 (4)編輯 收藏

            夢想從這里開始——觀奧運(yùn)圣火傳遞感言

            昨天晚上11點鐘,其實我正在寫那個pots,俺們班長突然跑過來叫我寫份觀奧運(yùn)圣火的感言,汗~沒辦法,奧運(yùn)啊,不能拒絕的,所以就寫了份,反正也不是太重要,發(fā)到博客上也可以順便保存下 呵呵。

             

             

            夢想從這里開始

            527,對于每一個南京人都有著特殊的意義,因為今天——奧運(yùn)圣火將在在南京傳遞,為了親自迎接奧運(yùn)圣火,計算機(jī)學(xué)院07級的全體同學(xué),穿著整齊的奧運(yùn)T恤衫,早早的等候在火炬手將要出現(xiàn)的地方。當(dāng)奧運(yùn)圣火出現(xiàn)的那一刻,我非常的激動,在我有生之年能和奧運(yùn)圣火零距離的接觸,那種感覺真是無法表達(dá)出來來的!!我們手中揮舞著奧運(yùn)五環(huán)旗和鮮艷的五星紅旗,高喊著:“北京加油!奧運(yùn)加油!汶川挺住,中國加油。”即使嗓子嘶啞了,也無法澆滅我們心中的那股激動之情。因為國殤之后生活傳遞已經(jīng)被賦予了更多的內(nèi)涵,是我們民族信心傳遞,也是我們民族愛心的傳遞,象征著我們的奧運(yùn)情,愛國心!

            我想:奧運(yùn)圣火就像太陽一樣照亮每個人的心靈,點燃每個人心中深埋已久的夢想。其實我們每個人的心里都有一把火炬,不同的是,火炬手們傳遞的是和平團(tuán)結(jié)的奧運(yùn)精神,而我們志愿者,傳遞的則是中國人——南京人的熱情與文明!

            --weitao

             


            posted @ 2009-03-01 13:27 abilitytao 閱讀(198) | 評論 (0)編輯 收藏

            POJ 3414-Pots BFS (代碼好長啊 ,建議大家不要看了)

                 摘要: 有史以來寫的最爛的一個程序,居然寫到5000B,勉強(qiáng)16MS AC.題意就是有名的倒水游戲,給你2個一定容量的容器,然后要求你配出一定兩的溶液并輸出每一步的決策;此題的算法當(dāng)然是BFS啦,不過貌似有人告訴我說數(shù)論里有更好的方法,我感覺也是這樣,我寫的代碼實在是有點冗長。。。    algorithm=搜索+回溯。   有這幾個字就足夠了;值得一提的...  閱讀全文

            posted @ 2009-03-01 01:10 abilitytao 閱讀(1048) | 評論 (0)編輯 收藏

            POJ 3087-Shuffle'm Up(洗牌游戲) 模擬題

            題目大意就洗兩副牌,重復(fù)不停地洗,直到出現(xiàn)給定的順序為止 輸出洗牌步數(shù)即可,簡單模擬一下洗牌和分牌的動作 這道題就不難了
            呵呵 AC這道題只用了20分鐘;
            不過我有點弄不明白的是網(wǎng)上都說這個題是BFS?我怎么感覺一點也不像啊???
            #include <iostream>
            #include
            <algorithm>
            #include
            <cmath>
            #include 
            <cstring>
            using namespace std;

            char origin1[200];
            char origin2[200];
            char mix[1000];
            char des[1000];
            int c;

            void shuffle(char a[],char b[])
            {
                
            int i=0;
                
            int j=0;
                
            int pos=0;
                
            int flag=1;

                
            while(pos<=2*c-1)
                
            {
                    
            if(flag==1)
                    
            {

                        mix[pos]
            =b[i];
                        j
            ++;
                        pos
            ++;
                        flag
            =2;
                    }

                    
            else if(flag==2)
                    
            {
                        mix[pos]
            =a[i];
                        i
            ++;
                        pos
            ++;
                        flag
            =1;
                    }

                    mix[pos]
            ='\0';


                }

            }


            void separate()
            {
                
            int i;
                
            for(i=0;i<c;i++)
                    origin1[i]
            =mix[i];
                
            for(i=c;i<2*c;i++)
                    origin2[i
            -c]=mix[i];
                origin1[c]
            ='\0';
                origin2[c]
            ='\0';
            }



            int main ()
            {
                
            int step;
                
            int testcase;
                
            int i;
                
            char test1[200];
                
            char test2[200];
                
            int flag;
                scanf(
            "%d",&testcase);
                
            for(i=1;i<=testcase;i++)
                
            {
                    flag
            =0;
                    step
            =0;
                    scanf(
            "%d",&c);
                    scanf(
            "%s",origin1);
                    scanf(
            "%s",origin2);
                    scanf(
            "%s",des);
                    strcpy(test1,origin1);
                    strcpy(test2,origin2);
                    
            while(1)
                    
            {
                        shuffle(origin1,origin2);
                        step
            ++;
                        
            if(strcmp(mix,des)==0)
                            
            break;

                        separate();
                        
            if(strcmp(test1,origin1)==0&&strcmp(test2,origin2)==0)
                        
            {
                            flag
            =1;
                            
            break;
                        }


                    }

                    
            if(flag==0)
                        printf(
            "%d %d\n",i,step);
                    
            else
                        printf(
            "%d -1\n",i);
                }

                system(
            "pause");
                
            return 0;
            }

            posted @ 2009-02-28 20:06 abilitytao 閱讀(1392) | 評論 (5)編輯 收藏

            POJ 3126-Prime Path 廣度優(yōu)先搜索BFS

                 摘要: 不知道數(shù)論里面是不是有相關(guān)的公式,總之這道題我做的有點暴力,呵呵,一個BFS搞定;要說具體的算法的話,就是【】【】【】【】這 四個數(shù)位按從左到右的順序每次改變一個位置上的數(shù)字,如果這個數(shù)字是質(zhì)數(shù),就把它放入隊列,并記錄下到達(dá)這個數(shù)字所要經(jīng)歷的步數(shù)即可,然后循環(huán)搜索,搜到跳出。。。有點遺憾的是,這道題我寫的有點長,如果你有更好的想法,不妨告訴我哦 謝謝啦O(∩_∩)O~ #...  閱讀全文

            posted @ 2009-02-27 22:31 abilitytao 閱讀(1319) | 評論 (0)編輯 收藏

            數(shù)學(xué)建模——商人過河問題 Beta2.0

                 摘要: 早知道要寫這么長 就用類寫了 呵呵//copyright by abilitytao,Nanjing University of Science and Technology//thanks to Mr Xu Chungen//本程序在商人數(shù)<=1000,隨從數(shù)<=1000時測試通過,其余數(shù)據(jù)不能保證其正確性.#include<iostream>#include <w...  閱讀全文

            posted @ 2009-02-26 20:06 abilitytao 閱讀(3568) | 評論 (9)編輯 收藏

            數(shù)學(xué)建模之——商人過河問題 算法核心:搜索法

                 摘要: 問題描述: 三個商人各帶一個隨從乘船過河,一只小船只能容納2人,由他們自己劃船。三個商人竊聽到隨從們密謀,在河的任意一岸上,只要隨從的人數(shù)比商人多,就殺掉商人。但是如何乘船渡河的決策權(quán)在商人手中,商人們?nèi)绾伟才哦珊佑媱澊_保自身安全?數(shù)學(xué)建模課上,老師給我們出了這樣一個問題,要我們編程解決,呵呵,于是,就寫了下面這個程序,這個程序適用于商人數(shù)和隨從數(shù)都《=1000的情況,并且約定小船的容量為2,此程...  閱讀全文

            posted @ 2009-02-26 11:07 abilitytao 閱讀(9232) | 評論 (15)編輯 收藏

            僅列出標(biāo)題
            共42頁: First 34 35 36 37 38 39 40 41 42 
            蜜臀av性久久久久蜜臀aⅴ| 99久久国产综合精品网成人影院 | 中文精品久久久久人妻| 91麻豆国产精品91久久久| 欧美黑人激情性久久| 91精品国产综合久久四虎久久无码一级 | 久久香蕉综合色一综合色88| 精品久久久无码中文字幕| 久久大香萑太香蕉av| www.久久精品| 久久精品青青草原伊人| 日韩精品久久久久久| 99精品久久精品一区二区| 久久激情亚洲精品无码?V| 久久w5ww成w人免费| 久久无码专区国产精品发布| 日本免费一区二区久久人人澡 | 久久本道伊人久久| 久久久久久久97| 久久99精品久久久久久不卡| 久久精品国产亚洲av麻豆小说| 久久久久久久久久久免费精品| 久久精品国产亚洲AV大全| 国产亚洲精久久久久久无码77777| 久久电影网2021| 久久精品国产亚洲AV无码娇色| 精品久久久久久无码不卡| 久久嫩草影院免费看夜色| 51久久夜色精品国产| 狠狠久久亚洲欧美专区| 热re99久久精品国99热| 亚洲午夜久久久久妓女影院| 久久婷婷色香五月综合激情| 亚洲国产成人久久一区WWW| 久久精品无码免费不卡| 久久精品国产99久久丝袜| 93精91精品国产综合久久香蕉| 欧美亚洲国产精品久久蜜芽| 亚洲国产成人久久综合一| 亚洲狠狠综合久久| 精品国产综合区久久久久久|