[問題] 二維動態陣列的問題

看板C_and_CPP (C/C++)作者 (Hank)時間7年前 (2018/12/27 01:54), 編輯推噓2(202)
留言4則, 4人參與, 7年前最新討論串1/1
開發平台(Platform): (Ex: Win10, Linux, ...) Linux 編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出) gcc 問題(Question): 各位大神大家好,小弟正在做資料結構的作業,因為就教授要求必須用二為維動態陣列, 但是遇到一些錯誤狀況,在delete的時候會跑出錯誤狀況: Error:free(): invalid next size(fast) 餵入的資料(Input): n 為 欲排列的個數 amax amin 為產生隨機變數區間 rseed 為種子 預期的正確結果(Expected Output): 錯誤結果(Wrong Output): Error:free(): invalid next size(fast) 程式碼(Code):(請善用置底文網頁, 記得排版,禁止使用圖檔) https://ideone.com/GIdoRv 補充說明(Supplement): -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.173.139.63 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1545846887.A.BB1.html

12/27 08:36, 7年前 , 1F
new迴圈從0開始,delete迴圈要<n,而且只配一個row, 要 <1
12/27 08:36, 1F

12/27 08:40, 7年前 , 2F
你的new為什麼是從i=1開始?
12/27 08:40, 2F

12/27 21:34, 7年前 , 3F
不用 new 就不用 delete 了,善用 std::vector
12/27 21:34, 3F

12/28 02:18, 7年前 , 4F
xD 你需要先把 insertion sort 寫好再來挑戰 merge sort
12/28 02:18, 4F
文章代碼(AID): #1S8y1dkn (C_and_CPP)
文章代碼(AID): #1S8y1dkn (C_and_CPP)