• <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 閱讀(341) 評論(0)  編輯 收藏 引用 所屬分類: Algorithm
            <2010年3月>
            28123456
            78910111213
            14151617181920
            21222324252627
            28293031123
            45678910

            常用鏈接

            留言簿(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

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            成人久久精品一区二区三区| 亚洲成av人片不卡无码久久| 久久久久久精品久久久久| 人人狠狠综合88综合久久| 香蕉久久夜色精品国产尤物| 色8久久人人97超碰香蕉987| 国产精品久久免费| 国内精品久久久久国产盗摄| 亚洲国产精品无码久久青草| 人妻少妇久久中文字幕一区二区| 久久国产精品无码HDAV| 久久免费视频一区| 久久66热人妻偷产精品9| 久久久久久亚洲精品不卡| 久久综合亚洲欧美成人| 久久www免费人成看国产片| 亚洲综合精品香蕉久久网| 国产精品日韩欧美久久综合| 77777亚洲午夜久久多喷| 国产精品午夜久久| 久久精品无码专区免费青青| 久久亚洲精品国产精品婷婷| 国产精品视频久久| 亚洲乱码精品久久久久.. | 久久久久久久久66精品片| 人妻无码αv中文字幕久久琪琪布 人妻无码久久一区二区三区免费 人妻无码中文久久久久专区 | 久久精品aⅴ无码中文字字幕重口| 久久国产精品一区| 色综合久久中文综合网| 人妻无码αv中文字幕久久琪琪布| 久久久久久久91精品免费观看| 精品国产乱码久久久久久浪潮| 久久国产乱子伦精品免费强| 无码AV波多野结衣久久| 久久精品国产亚洲AV影院 | 亚洲国产精品无码久久98| 欧美粉嫩小泬久久久久久久| 久久精品?ⅴ无码中文字幕| 久久99精品久久久久久野外| 国产成人久久精品麻豆一区| 国产AⅤ精品一区二区三区久久|