精華區beta EE_DSnP 關於我們 聯絡資訊
※ 引述《samuelduan ()》之銘言: : 在寫 MTDeleteCmd的時候 會用到rnGen()這個函數 : 根據老師在 Homework_4.pdf 上的說法 : rnGen(num) 中 輸入 num 的範圍應是 0 ~ (_objList or _arrList array size -1) : 但是我發現使用時 都不能產生和測試程式一樣的結果 : 聽同學說才知道 要將範圍改成 0 ~ (_objList or _arrList array size) (沒有減1) : 才會和測試程式產生一樣的亂數 : 所以是我有點理解錯誤 : 還是這也是 ref code 的一個 bug... rnGen(range) 這個 function 會產生 [0, range - 1] 之間的亂數. 所以要產生 "0 ~ (_objList or _arrList array size -1)" 的 index, 必須傳入 rnGen(_objList.size()) or rnGen(_arraySize()). Please refer to "rnGen.h" for details. --- Sorry for the confusion... I should have told you earlier... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.112.21.240
samuelduan:謝謝 :) 12/14 08:35