知識社群登入
srand() 和 rand() 的使用方法
by 高顯忠, 2010-12-20 09:55, 人氣(2505)
#if 0

#endif
// ----------------------------------------------

#include <cstdlib>
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <time.h>
// ----------------------------------------------

using namespace std;
// ----------------------------------------------

int main(int argc, char *argv[])
{
   int i;

   // srand((unsigned) time(NULL));
   srand(327);
   for(i= 0;i<10;i++) {
      printf( "  %3d", (rand()%100));
   }
    
    printf("\n");
    system("PAUSE");
    
    return EXIT_SUCCESS;
}// end of main()