[問題] 初學請教:計數排序問題

看板C_and_CPP (C/C++)作者 (沙皮哥)時間7年前 (2018/11/06 16:16), 7年前編輯推噓2(204)
留言6則, 3人參與, 7年前最新討論串1/1
開發平台(Platform): (Ex: Win10, Linux, ...) Win10 編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出) MinGW + VS Code 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) 問題(Question): 大家好我是C++初學者在練習這個問題時 http://bit.ly/2yTqpHW 進入countSort function後會回不到main function 我的錯誤是進到 C:\MinGW\lib\gcc\mingw32\6.3.0\include\c++\ext\new_allocator.h void deallocate(pointer __p, size_type) { ::operator delete(__p); } 產生error 不知道是不是我VS Code沒裝好有問題還是? 餵入的資料(Input): 預期的正確結果(Expected Output): 錯誤結果(Wrong Output): 進入countSort function後會回不到main function 程式碼(Code):(請善用置底文網頁, 記得排版,禁止使用圖檔) http://bit.ly/2yTqpHW 補充說明(Supplement): 初次在這個版發文,有錯請見諒>< -- jkkert:https://imgur.com/JhKKuFX
jkkert:汪汪汪汪汪 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.96.89.26 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1541492180.A.399.html

11/06 16:47, 7年前 , 1F
29行
11/06 16:47, 1F
d大可以再說明清楚一點嗎? 因為我設breakpoint 在那段迴圈之後是可以執行的 不知道該怎麼改比較好? 謝謝 ※ 編輯: jkkert (140.96.89.26), 11/06/2018 17:10:10

11/06 18:04, 7年前 , 2F
你用vector的話 把所有[]改成.at 有助於你debug
11/06 18:04, 2F

11/06 18:05, 7年前 , 3F
沒認真看 不過一樓說29行的話大概就是越界了
11/06 18:05, 3F
我剛剛試過那段只跑3個迴圈也有問題QQ 看起來不是越界 我再debug看看,謝謝 ※ 編輯: jkkert (140.96.89.26), 11/06/2018 18:12:38

11/07 00:07, 7年前 , 4F
你全部用.at就知道了 是越界
11/07 00:07, 4F

11/07 00:07, 7年前 , 5F
21行 range的index跟vec的index你多想一下
11/07 00:07, 5F

11/07 00:49, 7年前 , 6F
你其中一段邏輯有問題
11/07 00:49, 6F
debug完了,謝謝大家~~~ ※ 編輯: jkkert (140.96.89.26), 11/07/2018 08:43:39
文章代碼(AID): #1RuKtKEP (C_and_CPP)
文章代碼(AID): #1RuKtKEP (C_and_CPP)