BSJ1995
BSJ1995
2016-05-02 11:00
采纳率: 10%
浏览 1.5k

数据结构c++循环单链表问题,急!!

CirSinglyList& operator+=(CirSinglyList &list) //尾插入list,集合并

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • ArthurJava
    ArthurJava 2016-05-02 12:41
     CirSinglyList& operator+=(CirSinglyList &list)
     {
         CirSinglyList *p = this;
         while(p->next != NULL)
             p = p->next;
         while(list->next != NULL)
         {
             p->next = new CirSinglyList();
             p->next = list;
             p = p->next;
         }
         p->next = NULL;
         return this;
     }
     CirSinglyList & operator=(CirSinglyList &list)
     {
     /* 自己写 */
     }
    
    点赞 评论
  • ArthurJava
    ArthurJava 2016-05-02 15:00

    修改一下

      CirSinglyList& operator+=(CirSinglyList &list)
     {
         CirSinglyList *p = this;
         while(p->next != NULL)
             p = p->next;
         while(list->next != NULL)
         {
             p->next = new CirSinglyList();
             p->next = list;
             p = p->next;
            list = list->next;
         }
         p->next = NULL;
         return this;
     }
     CirSinglyList& operator=(CirSinglyList &list)
     {
     /* 自己写 */
     }
    
    点赞 评论

相关推荐