srand() 和 rand() 的使用方法
by 高顯忠, 2010-12-20 09:55, Views(2907)
#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()