#include<stdio.h> #include<stdlib.h> #include<time.h> void main() { /*srand:随机数发生器,根据时间*/ /*time是一个函数,获取时间,赋值给time1*/ time_t time1; srand((unsigned int)time(&time1)); int num = rand() % 100;//100以内随机数;1000之内:%1000 int num2 = rand() % 100 + 100;//100到200之内的随机数 system("pause"); }