Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/137.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在C++; 在java中有一个答案,但是寻找一些应用于C++的东西。这段代码可以工作(有点),但会进入一个无限循环。任何建议都将不胜感激 void mirror(ListType & list) { ListType listMirror = NULL; Node *p = list; listMirror = p; listMirror->next = NULL; Node *q = listMirror; while (list->next != NULL){ p = p->next; listMirror = p; q = listMirror->next; p->next; if (p = q)(list->next = NULL); } list->next = listMirror; }_C++_Linked List_Mirror - Fatal编程技术网

如何在C++; 在java中有一个答案,但是寻找一些应用于C++的东西。这段代码可以工作(有点),但会进入一个无限循环。任何建议都将不胜感激 void mirror(ListType & list) { ListType listMirror = NULL; Node *p = list; listMirror = p; listMirror->next = NULL; Node *q = listMirror; while (list->next != NULL){ p = p->next; listMirror = p; q = listMirror->next; p->next; if (p = q)(list->next = NULL); } list->next = listMirror; }

如何在C++; 在java中有一个答案,但是寻找一些应用于C++的东西。这段代码可以工作(有点),但会进入一个无限循环。任何建议都将不胜感激 void mirror(ListType & list) { ListType listMirror = NULL; Node *p = list; listMirror = p; listMirror->next = NULL; Node *q = listMirror; while (list->next != NULL){ p = p->next; listMirror = p; q = listMirror->next; p->next; if (p = q)(list->next = NULL); } list->next = listMirror; },c++,linked-list,mirror,C++,Linked List,Mirror,列表的类型为“ListType”,而p的类型为“Node”,这会导致while循环上出现未定义的行为(因为它显然是编译的) 改变这个 Node *p = list; 指向列表中的第一个成员 Node *p = list.firstMemeber()//this is an example, refer to your documentation 旁注:使用nullptr。NULL已经过时了。也许只有我一个人,但阅读这些代码会让人感到困惑和痛苦。你认为下一步是什么在做什么?对不起,应该

列表的类型为“ListType”,而p的类型为“Node”,这会导致while循环上出现未定义的行为(因为它显然是编译的)

改变这个

    Node *p = list;
指向列表中的第一个成员

Node *p = list.firstMemeber()//this is an example, refer to your documentation

旁注:使用nullptr。NULL已经过时了。也许只有我一个人,但阅读这些代码会让人感到困惑和痛苦。你认为下一步是什么在做什么?对不起,应该提到“ListType”等同于“typedef节点*ListType”。
Node *p = list.firstMemeber()//this is an example, refer to your documentation