看板 NCKU_CSIE93 關於我們 聯絡資訊
※ 引述《foxkid (只有冰與雪)》之銘言: : ※ 引述《chys49 (丿嘎)》之銘言: → boypower:time()當seed應該滿均勻的 要不要貼code看看 10/07 01:53 → foxkid:其實rand()也只是去查亂數表 seed是告訴他從那邊開始查 10/07 13:30 → foxkid:像boypower所說 time()已經滿均勻了 不然可以換clock? XD 10/07 13:31 → chys49:若用time()有時亂數會重複,而且每次執行時會有某些區間很 10/08 11:43 → chys49:集中,除非讓時間夠長,所以努力K原文書中~~不知道方向對不對 10/08 11:47 有個function叫做clock() , 定義在time.h裡面 以下節錄自MSDN: The elapsed wall-clock time since the start of the process (elapsed time in seconds times CLOCKS_PER_SEC). If the amount of elapsed time is unavailable, the function returns –1, cast as a clock_t. 簡單的說就是回傳process活了多少個clock,要換成時間的話除以CLOCKS_PER_SEC。 Example: clock_t start, finish; double duration; start = clock(); ... finish = clock(); duration = (double)(finish - start) / CLOCKS_PER_SEC; 若單單只看clock()的回傳值,應該是一個遞增的數字,也許可以滿足你的要求。 試試看吧~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 219.87.142.18 ※ 編輯: foxkid 來自: 219.87.142.18 (10/08 12:00)
chys49:謝謝^^ 又多認識一個function~~謝謝^o^ 10/09 08:20