scanf("%d",&seed);srand(seed); // 初始化随机数生成器 for (i=0;i<=15;i++) m[i] = 0;while (nn < 10 ){ // r 是双精度浮点随机数,范围0.0到1.0 r = ( (double)rand() / ((double)(RAND_MAX)+(double)(1)) );i =(int) ( r * 15.0);if (m[i] == 0)...
double r = (rand()%1000)/1000.0
需要首先使用随机数“种子”初始化,srand函数:#i nclude <stdlib.h>#i nclude <stdio.h>#i nclude //使用当前时钟做种子void main( void ){int i;srand( (unsigned)time( NULL ) );//初始化随机数/* 打印10个随机数. */for( i = 0; i < 10;i++ )printf( " %d\n", rand(...