• <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)寒,忽然年以殘,念往昔,語默心酸。二十光陰無一物,韶光賤,寐難安; 不畏形影單,道途阻且慢,哪曲折,如渡飛湍。斬浪劈波酬壯志,同把酒,共言歡! -如夢令

            #

            動(dò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;//定義堆棧的動(dòng)態(tài)容量
            public:
                mystack();
            //重載默認(rèn)構(gòu)造函數(shù)
                int push(int num);//壓棧操作
                int pop();//退棧操作
                int top();//返回棧頂元素
                int size();//返回堆棧的實(shí)際容量
                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 閱讀(1090) | 評(píng)論 (3)編輯 收藏

            動(dòng)態(tài)循環(huán)隊(duì)列模板類——鏈表實(shí)現(xiàn)

             

            //template_by_abilitytao_ACM
            //Begin_template_myqueue
            //這是一個(gè)非常高效的循環(huán)鏈表隊(duì)列
            #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)//入隊(duì)成功返回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()//如果出隊(duì)成功返回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()//隊(duì)列為空返回0,否則返回隊(duì)首元素的值
            {

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

            }


            int myqueue::rear()//隊(duì)列為空返回值為0,否則返回隊(duì)尾元素的值
            {
                
            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í)函數(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 閱讀(1636) | 評(píng)論 (0)編輯 收藏

            A*算法詳解——by Sunway

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

            posted @ 2009-03-01 21:34 abilitytao 閱讀(6449) | 評(píng)論 (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 閱讀(6527) | 評(píng)論 (4)編輯 收藏

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

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

             

             

            夢想從這里開始

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

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

            --weitao

             


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

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

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

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

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

            題目大意就洗兩副牌,重復(fù)不停地洗,直到出現(xiàn)給定的順序?yàn)橹?輸出洗牌步數(shù)即可,簡單模擬一下洗牌和分牌的動(dòng)作 這道題就不難了
            呵呵 AC這道題只用了20分鐘;
            不過我有點(diǎn)弄不明白的是網(wǎng)上都說這個(gè)題是BFS?我怎么感覺一點(diǎn)也不像啊???
            #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 閱讀(1394) | 評(píng)論 (5)編輯 收藏

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

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

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

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

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

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

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

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

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

            僅列出標(biāo)題
            共42頁: First 34 35 36 37 38 39 40 41 42 
            久久精品国产一区二区三区日韩| 国产精品VIDEOSSEX久久发布| 99久久这里只精品国产免费| 久久久一本精品99久久精品88| 久久亚洲精品国产精品| 久久亚洲高清观看| 亚洲色欲久久久综合网| 国产精品免费久久久久影院| 久久久久波多野结衣高潮| 精品久久一区二区三区| A级毛片无码久久精品免费| 久久国产精品国语对白| 国产精品久久久久久久久| 欧美亚洲国产精品久久| 亚洲国产精品综合久久网络| 久久久久亚洲AV片无码下载蜜桃| 久久播电影网| 国产精品久久久久久久久免费| 久久婷婷色综合一区二区| 国产精品伦理久久久久久| 久久免费的精品国产V∧| 久久99精品国产麻豆宅宅| 久久久精品国产亚洲成人满18免费网站 | 欧美亚洲另类久久综合| 亚洲AV日韩AV永久无码久久| 亚洲欧洲精品成人久久曰影片| 99久久人人爽亚洲精品美女| 精品国产福利久久久| 99久久777色| 97久久超碰国产精品2021| 久久综合国产乱子伦精品免费| 久久婷婷五月综合成人D啪| 亚洲欧美日韩精品久久亚洲区 | 午夜久久久久久禁播电影| 一本久久精品一区二区| 色婷婷久久久SWAG精品| 久久久久一本毛久久久| 香蕉99久久国产综合精品宅男自 | 久久精品人人做人人爽97| 久久天天躁狠狠躁夜夜躁2O2O| 99久久国产精品免费一区二区 |