- 728 名前:デフォルトの名無しさん mailto:sage [2012/01/27(金) 17:01:26.43 ]
- >>717
処理系によっては、1回目の値が前回実行時と大差ないものがあり、RAND_MAXで割ると0.6あたりをウロウロしたりする。 #include <stdio.h> #include <stdlib.h> #include <time.h> int main(void) { srand((unsigned int)time(0)); printf("%d¥n", rand()); return 0; } 上記コードを3回実行してみると、 gcc version 4.2.1 (Apple Inc. build 5664)では 1470289798 1470306605 1470306605 codepad.org/ では 121543468 627453109 1744218406 応急回避方法は、0~9が必要なら、rand() % 10
|

|