次のコードを検討してください。
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main ()
{
int ctr;
for(ctr=0;ctr<=10;ctr++)
{
int iSecret;
srand ( time(NULL) );
printf("%d\n",iSecret = rand() % 1000 + 1);
}
}
そして、これを出力します: 256 256 256 256 256 256 256 256 256 256
残念ながら、そのループで 10 個の異なる乱数を出力する必要があります。