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

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

            #

            動態鏈表式堆棧 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;//定義堆棧的動態容量
            public:
                mystack();
            //重載默認構造函數
                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,操作成功返回所需要的整數;
            {
                
            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 閱讀(1091) | 評論 (3)編輯 收藏

            動態循環隊列模板類——鏈表實現

             

            //template_by_abilitytao_ACM
            //Begin_template_myqueue
            //這是一個非常高效的循環鏈表隊列
            #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有可能嗎?如果內存不夠系統內部有 返回值嗎,猜:返回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()//為了提高本模板的兼容性,故提供此函數,其實函數的返回值永遠不可能為1;
            {
                
            return false;
            }

            //endtemplate_by_abilitytao_ACM

            ////////////////////////////////////////////////////////////////////下面是測試數據////////////////////////////////////////////////////////////////////////////
            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 閱讀(1637) | 評論 (0)編輯 收藏

            A*算法詳解——by Sunway

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

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

            夢想從這里開始——觀奧運圣火傳遞感言

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

             

             

            夢想從這里開始

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

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

            --weitao

             


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

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

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

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

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

            題目大意就洗兩副牌,重復不停地洗,直到出現給定的順序為止 輸出洗牌步數即可,簡單模擬一下洗牌和分牌的動作 這道題就不難了
            呵呵 AC這道題只用了20分鐘;
            不過我有點弄不明白的是網上都說這個題是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 閱讀(1394) | 評論 (5)編輯 收藏

            POJ 3126-Prime Path 廣度優先搜索BFS

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

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

            數學建模——商人過河問題 Beta2.0

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

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

            數學建模之——商人過河問題 算法核心:搜索法

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

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

            僅列出標題
            共42頁: First 34 35 36 37 38 39 40 41 42 
            久久露脸国产精品| 日本精品久久久久中文字幕| 亚洲精品成人网久久久久久| 模特私拍国产精品久久| 日日躁夜夜躁狠狠久久AV| 国产午夜福利精品久久2021| 久久亚洲精品无码播放| 日韩精品久久无码中文字幕| 久久精品国产99国产精品澳门| 久久97久久97精品免视看秋霞 | 亚洲?V乱码久久精品蜜桃| 久久久精品国产免大香伊 | 欧美日韩中文字幕久久久不卡| 影音先锋女人AV鲁色资源网久久| 91精品国产91久久久久久| 亚洲欧洲久久久精品| 99久久www免费人成精品| 久久夜色精品国产噜噜噜亚洲AV| 久久国产成人| 亚洲国产精品婷婷久久| 久久99精品国产自在现线小黄鸭| 亚洲精品美女久久久久99小说| 7国产欧美日韩综合天堂中文久久久久 | 久久精品国产精品国产精品污| 一本色综合网久久| 无码八A片人妻少妇久久| 国产精品伦理久久久久久| 狠狠色丁香久久综合婷婷| 久久久久无码精品国产不卡| 久久久久久综合网天天| 污污内射久久一区二区欧美日韩| 久久青青草原精品影院| 久久久久四虎国产精品| 久久中文字幕一区二区| 久久国产精品久久国产精品| www.久久热| 亚洲乱亚洲乱淫久久| 久久人人爽人人精品视频| 亚洲国产成人久久一区久久| 久久久久久噜噜精品免费直播| 久久综合色区|