• <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>
            posts - 297,  comments - 15,  trackbacks - 0
            #include <iostream>

            using namespace std;

            //single link
            struct slink_t{
                struct slink_t* next;
                int data;
                slink_t(): next(0), data(0){
                }
                slink_t(slink_t* p, int d): next(p), data(d){
                }
            };

            /*output data of single link */
            ostream& operator<< (ostream& os, const struct slink_t* p)
            {
                cout << "Output : ";
                while (p && cout << p->data << ' ')
                    p = p->next;
                return os;
            }

            /* reverse the single link */
            struct slink_t* slink_reverse(struct slink_t* p)
            {
                struct slink_t* t = NULL, *tp = NULL;
                while (p)
                {
                    tp = t;
                    t = p;
                    p = p->next;
                    t->next = tp;
                }
                return t;
            }

            //double link
            struct dlink_t{
                struct dlink_t* next;
                struct dlink_t* prev;
                int data;
                dlink_t(): next(0), prev(0), data(0){
                }
                dlink_t(dlink_t* n, dlink_t* p, int d): next(n), prev(p), data(d){
                }
            };

            /* output data of double link */
            ostream& operator<< (ostream& os, const struct dlink_t* p)
            {
                cout << "Output : ";
                while (p && cout << p->data << ' ')
                    p = p->next;
                return os;
            }

            /* reverse the double link */
            struct dlink_t* dlink_reverse(struct dlink_t* p)
            {
                struct dlink_t* t = NULL;
                while (p)
                {
                    t = p;
                    p = p->next;
                    t->next = t->prev;
                    t->prev = p;
                }
                return t;
            }

            #define TEST__

            #ifdef TEST__
            /* test */
            int main()
            {
                struct slink_t* sl = new slink_t(new slink_t(new slink_t(new slink_t(new slink_t(new slink_t(NULL, 6), 5), 4), 3), 2), 1);
                cout << sl << endl;
                sl = slink_reverse(sl);
                cout << sl << endl;
                struct dlink_t* dl = NULL;
                struct dlink_t* h = new dlink_t(NULL, dl, 1);
                dl = h;
                for (int i = 2; i < 10; i++)
                {
                    struct dlink_t* t = new dlink_t(NULL, dl, i);
                    dl->next = t;
                    dl = t;
            //        dl->prev->next = dl;
                }
                cout << h << endl;
                h = dlink_reverse(h);
                cout << h << endl;
                cout << "Hello world" << endl;
                return 0;
            }
            #endif
            轉自:
            http://blog.chinaunix.net/u3/101003/showart.php?id=2095827
            posted on 2009-11-21 18:41 chatler 閱讀(348) 評論(0)  編輯 收藏 引用 所屬分類: Algorithm
            <2009年5月>
            262728293012
            3456789
            10111213141516
            17181920212223
            24252627282930
            31123456

            常用鏈接

            留言簿(10)

            隨筆分類(307)

            隨筆檔案(297)

            algorithm

            Books_Free_Online

            C++

            database

            Linux

            Linux shell

            linux socket

            misce

            • cloudward
            • 感覺這個博客還是不錯,雖然做的東西和我不大相關,覺得看看還是有好處的

            network

            OSS

            • Google Android
            • Android is a software stack for mobile devices that includes an operating system, middleware and key applications. This early look at the Android SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language.
            • os161 file list

            overall

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            97久久精品午夜一区二区| 亚洲成色999久久网站| 伊人色综合久久天天人守人婷| 久久久久亚洲精品男人的天堂| 一级a性色生活片久久无| WWW婷婷AV久久久影片| 99久久99久久精品国产片果冻| 久久天天日天天操综合伊人av| 久久成人国产精品免费软件| MM131亚洲国产美女久久| 99久久做夜夜爱天天做精品| 亚洲国产精久久久久久久| 久久午夜夜伦鲁鲁片免费无码影视| 人妻少妇久久中文字幕| 亚洲欧洲精品成人久久曰影片| 久久激情亚洲精品无码?V| 青春久久| 狠狠色综合久久久久尤物| 精品国产乱码久久久久久人妻| 九九热久久免费视频| 久久免费小视频| 9久久9久久精品| 精品国产乱码久久久久久郑州公司 | 久久香蕉国产线看观看猫咪?v| 少妇人妻88久久中文字幕| 亚洲&#228;v永久无码精品天堂久久| 亚洲色大成网站www久久九| 亚洲精品美女久久久久99小说| 久久久久久亚洲精品不卡| 欧美久久综合性欧美| 久久国产精品无码一区二区三区| 精品无码久久久久国产动漫3d| 99久久精品免费看国产一区二区三区 | 久久久精品久久久久影院| 久久WWW免费人成—看片| 亚洲午夜精品久久久久久人妖| 潮喷大喷水系列无码久久精品| 久久精品国产精品亚洲精品| 99麻豆久久久国产精品免费 | 欧美一区二区三区久久综合| 久久人人爽人人爽人人AV东京热|