int rand( void );#include <stdlib.h>
#include <stdio.h>
#include <time.h>void main( void )
{
   int i;   /* Seed the random-number generator with current time so that
    * the numbers will be different every time we run.
    */
   srand( (unsigned)time( NULL ) );   /* Display 10 numbers. */
   for( i = 0;   i < 10;i++ )
      printf( "  %6d\n", rand() );
}
Output    6929
    8026
   21987
   30734
   20587
    6699
   22034
   25051
    7988
   10104

解决方案 »

  1.   

    初始化:srand((unsigned)time( NULL ) );//使产生的随机数与时间有关,
                                          //即每次运行产生的随机数不同。
    int rand_number = rand();//产生一个随机数:0~RAND_MAX
    rand_number = rand_number*high/RAND_MAX+low//产生low~high之间的一
                                               //个随机数。
      

  2.   

    同意楼上,只要不用srand就行了。
      

  3.   

    a*x(1-x) a=3.9777654
    用这个公式就可以。
      

  4.   

    MS 的 rand()算法rand = ((rand * 214013L + 2531011L) >> 16) & 0x7fff ;