You should use the arc4random() function. It uses a superior algorithm to rand. You don't even need to set a seed.
Same as C, you would do
Feel free to substitute
random() or arc4random() for rand() (which is, as others have pointed out, quite sucky).srandom((unsigned int)time(NULL)); // 防止出現警告
生成[0, 1)之間的隨機數
arc4random_uniform(100) / 100.0 |
只有注冊用戶登錄后才能發表評論。 | ||
【推薦】100%開源!大型工業跨平臺軟件C++源碼提供,建模,組態!
![]() |
||
相關文章:
|
||
網站導航:
博客園
IT新聞
BlogJava
博問
Chat2DB
管理
|
||
|