谢谢了!

解决方案 »

  1.   

    The rand function returns a pseudorandom integer in the range 0 to RAND_MAX. Use the srand function to seed the pseudorandom-number generator before calling rand.
    可以 如下写:#define RAND_MAX 10
    float MyRand()
    {
       srand(RAND_MAX);
       return static_cast<float>(rand()) / 10.0;
    }
       
      

  2.   

    Math.random
    Class Overview | Class Members | This Package | All Packages Syntax
    public static synchronized double random() 
    Returns
    a pseudorandom double between 0.0 and 1.0. 
    Description
    Returns a random number between 0.0 and 1.0. Random number generators are often referred to as pseudorandom number generators because the numbers produced tend to repeat themselves after a period of time.
      

  3.   

    float  a = ( (float)rand() )/RAND_MAX;
      

  4.   

    float  a = ( (float)rand() )/RAND_MAX;
      

  5.   

    #include<stdlib.h>
    #include<time.h>
    srand(time(0));
    float a=((float)rand())/RAND_MAX;
    其中RAND_MAX是已定的产生随机树的最大的.具体可以看看msdn.