#include #include #include #define N 10main(){ int i;srand(time(0));/*设置种子,并生成伪随机序列*/for(i=0;i printf("%d\n",rand()%100);/*得到[0,99]伪随机数*/ system("pause");}
srand()设置种子rand()才得到随机数也就是先执行void srand(unsigned int seed)再执行int rand()如果种子不变,那么多次执行rand()得到的随机序列也是相同的所以经常以时间作为种子