vc中可以用哪个函数来产生随机数啊?

解决方案 »

  1.   

    #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() );
    }
      

  2.   

    我建的是MFC的单文档程序。
    要用哪个函数啊?
      

  3.   

    还是srand 和rand配合
    只要把头文件包含进去就可以
      

  4.   

    我建的是MFC的单文档程序。 和这个没有关系的,把头文件包进来就可以了