获取随机数
#include <stdlib.h> #include <stdio.h> #include <time.h> int main(void) { time_t t; srand((int)time(&t)); //srand(11);//则每次运行结果都一样,也就是说每次运行时必须使用不同的随机种子 printf("Random numbers from 0 to 99\n"); for(int i=0; i<10; i++) { printf("%d ", rand() % 100); } printf("\n"); return 0; }

浙公网安备 33010602011771号