9 若某程式語言之隨機亂數函式 rand()可回傳介於 0 至 1(包含 0 但不包含 1)的隨機實數,另函式 int(x)可回
傳實數參數 x 的整數值部分,今若要產生介於 1 至 6(包含 1 與 6)的隨機整數,可用以下何者算式?
(A)int(rand())*6
(B)int(6)+ rand()
(C)rand()*6+int(rand())
(D)int(rand()*6)+1
詳解 (共 1 筆)
未解鎖
rand產生小數點rand()*6變成0...
私人筆記 (共 1 筆)
未解鎖
取 1-10 的亂數 a=(rand()...