C语言生成随机数
#include <stdlib.h> #include <time.h> srand(time(NULL)); /* initialize random seed */ rand(); /* Generate a random int from 0 to RAND_MAX */ rand() % 100; /* Generate a random int from 0 to 99 */ rand() % 100 + 1; /* Generate a random int from 1 to 100 */ rand() % 30 + 100; /* Generate a random int from 100 to 129 */