引入头文件:
 
#include "sys/timeb.h"
 
随机数种子(毫秒):
 
srandom(time(NULL));
struct timeb timeSeed
;
ftime(&timeSeed
);
srand(timeSeed
.time 
* 1000 + timeSeed
.millitm
);  
 
随机数种子(秒):
 
unsigned int tseed 
= time(NULL);
srand(tseed
);
 
使用随机数:
 
int iRand 
= rand()%NUM
;            
                
                
                
        
    
转载请注明原文地址:https://tech.qufami.com/read-9968.html