iPhone随机数

随机数的三种方法:
1.    srand((unsigned)time(0));
        int i = rand() % 5;      

2.    srandom(time(0));
        int i = random() % 5;

3.    int i = arc4random() % 5 (常用) ;

 

参考:

http://www.cocoachina.com/bbs/read.php?tid=70719&keyword=%CB%E6%BB%FA%CA%FD

http://www.cocoachina.com/bbs/read.php?tid-2977-fpage-2-toread--page-1.html

http://www.codeios.com/thread-310-1-1.html

posted on 2011-11-16 13:25  uniy  阅读(970)  评论(0编辑  收藏  举报

导航