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

            統計

            留言簿(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)  編輯 收藏 引用

            色婷婷综合久久久中文字幕| 国产激情久久久久影院老熟女| 久久国产精品国语对白| 热99re久久国超精品首页| 国产精品久久波多野结衣| 久久精品国产只有精品2020| 久久精品女人天堂AV麻| 久久精品国产2020| 婷婷久久综合| 99热都是精品久久久久久| 久久这里都是精品| 色欲综合久久躁天天躁| 国产精品久久久久影视不卡| 99久久免费国产精品特黄| 久久久久久av无码免费看大片| 亚洲人成伊人成综合网久久久| 久久福利片| 无码国内精品久久人妻麻豆按摩| 99久久婷婷免费国产综合精品| 婷婷久久精品国产| 久久久久国产精品人妻| 国产精品久久久久久久久久免费| 久久久国产精品亚洲一区| 久久99精品国产麻豆宅宅| 欧美噜噜久久久XXX| 婷婷久久久亚洲欧洲日产国码AV| 99久久国产免费福利| 久久99亚洲综合精品首页| 色综合色天天久久婷婷基地| 久久成人精品视频| 久久无码国产| 久久亚洲AV成人无码电影| 亚洲精品高清国产一久久| 久久精品国产一区二区| 久久久久se色偷偷亚洲精品av | 欧美日韩久久中文字幕| 国产高清美女一级a毛片久久w| 精品一久久香蕉国产线看播放| 久久精品亚洲乱码伦伦中文| 99久久er这里只有精品18| 亚洲伊人久久大香线蕉苏妲己|