用srand(time(0))产生随机数种子,然后再rand()%1000就可产生一个1000以内的随机数
#include#include#include#includeint main(){ int a; srand(unsigned(time(NULL))); a=rand()%(1000-100)+100; printf("%d\n",a); return 0;}