ぼるじょあがC/C++の宿題を片付けますYO! 35代目
■ このスレッドは過去ログ倉庫に格納されています
>(int)((double)100 * rand() / (RAND_MAX + 1.0))
rand() % 100でいいぞ
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void){
int i;
int randNums[100] = {0};
srand((unsigned int)time(0));
for(i = 0; i < 10000; ++i)
++randNums[rand() % 100];
for(i = 0; i < 100; ++i)
printf("%d ", randNums[i]);
return 0;
}
■ このスレッドは過去ログ倉庫に格納されています