• <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 閱讀(316) 評論(0)  編輯 收藏 引用


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


            青青草原综合久久大伊人精品| 女同久久| 99久久国产亚洲高清观看2024| 亚洲国产精品一区二区久久| 久久精品成人一区二区三区| 中文字幕乱码久久午夜| 99热成人精品免费久久| 无码任你躁久久久久久久| 波多野结衣中文字幕久久| 久久综合九色综合网站| 久久精品成人影院| av无码久久久久不卡免费网站| 亚洲伊人久久成综合人影院 | 久久这里只有精品首页| 久久人人爽人人人人爽AV| 久久综合九色综合久99| 色综合久久中文字幕无码 | 亚洲av伊人久久综合密臀性色| 婷婷久久综合九色综合98| 无码人妻久久一区二区三区免费| 色欲综合久久躁天天躁| 精品无码久久久久久久久久| 久久综合综合久久97色| 大伊人青草狠狠久久| 久久精品国产亚洲精品2020| 亚洲国产欧洲综合997久久| 久久久久久精品免费看SSS| 深夜久久AAAAA级毛片免费看| 久久久久99精品成人片三人毛片| 青青草国产成人久久91网| 成人久久精品一区二区三区| 国产午夜福利精品久久2021| 漂亮人妻被黑人久久精品| 久久精品国产亚洲av影院| 精品无码久久久久久尤物| 国产精品久久久久jk制服| 2021少妇久久久久久久久久| 97久久综合精品久久久综合| 99久久免费只有精品国产| 久久久久九九精品影院| 无码人妻久久一区二区三区蜜桃|