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

            EverSpring working shop

            To pursue creative ideas based on nature.

            統(tǒng)計(jì)

            留言簿(1)

            他山之石

            閱讀排行榜

            評論排行榜

            My C++ for Single LinkList Traverse

            #include "stdafx.h"



            //A singleList traverse algorithem using the recursive method
            #define MAXLEN 10

            class ListNode
            {
            public:
            ?? ?friend class List;
            ?? ?ListNode():link(NULL){};
            ?? ?ListNode(const int& item):data(item),link(NULL){};
            ?? ?~ListNode();
            private:
            ?? ?int data;
            ?? ?ListNode* link;
            };

            class List
            {
            public:
            ?? ?List():head(NULL),Length(0){};
            ?? ?List(ListNode* h):head(h){};
            ?? ?bool ListInitialize();
            ?? ?void Reverse1(ListNode*);
            ?? ?void Reverse2();
            private:
            ?? ?ListNode* head;
            ?? ?int Length;
            };

            bool List::ListInitialize()
            {
            ?? ?ListNode* new_node;
            ?? ?ListNode* curr_node = head;
            ?? ?while(Length < MAXLEN)
            ?? ?{
            ?? ??? ?new_node = new ListNode(getchar());
            ?? ??? ?if (curr_node == NULL)
            ?? ??? ?{
            ?? ??? ??? ?head = curr_node = new_node;
            ?? ??? ?}
            ?? ??? ?else
            ?? ??? ?{
            ?? ??? ??? ?curr_node->link = new_node;
            ?? ??? ??? ?curr_node = new_node;
            ?? ??? ?}
            ?? ??? ?Length++;
            ?? ?}
            ?? ?return true;
            }

            //Recursive reverse
            void List::Reverse1(ListNode* prenode)? //we must pass the prenode to the next traverse
            {
            ?? ?ListNode *currnode;

            ?? ?currnode = head;
            ?? ?if(head = NULL) return;
            ?? ?if(currnode->link == NULL)
            ?? ?{
            ?? ??? ?head = currnode;
            ?? ??? ?currnode->link = prenode;
            ?? ?}
            ?? ?else
            ?? ?{?? ??? ?
            ?? ??? ?head = currnode->link;
            ?? ??? ?currnode->link = prenode;
            ?? ??? ?Reverse1(currnode);? //currnode is acting as prenode of the next traverse
            ?? ?}
            }

            int main()
            {

            ?? ?List newList;
            ?? ?newList.ListInitialize();
            ?? ?newList.Reverse1(NULL);


            ?? ?return 0;
            }

            posted on 2008-04-13 16:45 everspring79 閱讀(313) 評論(0)  編輯 收藏 引用


            只有注冊用戶登錄后才能發(fā)表評論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            久久久噜噜噜久久熟女AA片| 国产精品美女久久久久网| 国产精品午夜久久| 久久精品国产亚洲7777| 久久综合视频网站| 亚洲国产精品无码久久久不卡| 精品久久久无码中文字幕天天| 久久精品这里热有精品| 欧美国产精品久久高清| 久久综合狠狠综合久久| 91精品国产91久久久久久青草| 久久亚洲精品无码观看不卡| 欧洲人妻丰满av无码久久不卡| 94久久国产乱子伦精品免费| 日韩AV毛片精品久久久| 久久精品国产秦先生| 久久久久久久精品妇女99| 国产真实乱对白精彩久久| 亚洲中文字幕无码久久2020| 一级做a爱片久久毛片| 亚洲第一极品精品无码久久| 爱做久久久久久| 久久精品国产亚洲网站| 18岁日韩内射颜射午夜久久成人| 亚洲国产精品婷婷久久| 精品久久8x国产免费观看| 精品久久久久久亚洲精品| 免费精品国产日韩热久久| 久久久国产精华液| 国内精品久久久久久久影视麻豆| 97久久久久人妻精品专区| 日韩AV无码久久一区二区 | 人人妻久久人人澡人人爽人人精品| 99精品久久精品一区二区| 少妇人妻88久久中文字幕| 国产精品久久婷婷六月丁香| 久久综合色区| 伊人情人综合成人久久网小说| 欧美午夜A∨大片久久| 内射无码专区久久亚洲| 久久亚洲AV无码精品色午夜麻豆|