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)); // 防止出現(xiàn)警告
生成[0, 1)之間的隨機(jī)數(shù)
arc4random_uniform(100) / 100.0 |
只有注冊用戶登錄后才能發(fā)表評論。 | ||
【推薦】100%開源!大型工業(yè)跨平臺軟件C++源碼提供,建模,組態(tài)!
![]() |
||
相關(guān)文章:
|
||
網(wǎng)站導(dǎo)航:
博客園
IT新聞
BlogJava
博問
Chat2DB
管理
|
||
|