作者joey11121 (Algorithmican)
看板C_and_CPP
标题[问题] Singly Linked List反转
时间Wed Feb 19 23:28:34 2020
开发平台(Platform): (Ex: Win10, Linux, ...)
Win10
编译器(Ex: GCC, clang, VC++...)+目标环境(跟开发平台不同的话需列出)
Dev-C++
额外使用到的函数库(Library Used): (Ex: OpenGL, ...)
无
问题(Question):
最近在学习Linked List,想实作反转Linked List,debug许久找不出为何无法印出反转後的Linked List
喂入的资料(Input):
无
预期的正确结果(Expected Output):
21 -> 15 -> 7 -> 2 -> NULL
2 -> 7 -> 15 ->21-> NULL
错误结果(Wrong Output):
21 -> 15 -> 7 -> 2 -> NULL
2 -> NULL
程式码(Code):(请善用置底文网页, 记得排版,禁止使用图档)
https://ideone.com/eWq4t5
补充说明(Supplement):
-----
Sent from JPTT on my iPad
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 119.14.9.131 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/C_and_CPP/M.1582126120.A.6A5.html
1F:→ djshen: 不如说说你怎麽debug的 02/19 23:32
2F:→ joey11121: 忘记考虑最後一个node不会进入while回圈,已解决 02/19 23:51
3F:→ joey11121: 所以回圈结束後要再做一次curr -> next = prev 02/19 23:52