2 bsj1995 BSJ1995 于 2016.05.02 19:00 提问

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

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

2个回答

ArthurJava
ArthurJava   2016.05.02 20: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 23: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)
 {
 /* 自己写 */
 }
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!