看板 C_and_CPP 關於我們 聯絡資訊
開發平台(Platform): (Ex: Win10, Linux, ...) Leetcode C++ *[36m問題(Question):*[m 小弟在寫這題 https://leetcode.com/problems/insertion-sort-list/ 我第 9 行如果不先把 cur->next 指定成 nullptr 執行時就會出現 heap-use-after-free 的錯誤 一時腦袋空空想不出來哪裡出錯了... 不曉得是甚摸原因 感謝各位前輩! 程式碼(Code):(請善用置底文網頁, 記得排版,禁止使用圖檔) http://codepad.org/hidj7vRl -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 180.177.3.109 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1616229569.A.043.html ※ 編輯: lemonsheep (180.177.3.109 臺灣), 03/20/2021 16:40:27
pinefruit: 第九行是不需要的,主要問題在於... 03/20 19:04
pinefruit: 當 cur 插到前面去時,原本 cur 所在位置的前後關係 03/20 19:05
pinefruit: 也需要處理。 03/20 19:06