#include <iostream> #include <time.h> int main() { srand((unsigned)time(NULL));//srand()就是给rand()提供种子seed for (int i = 0; i < 100; i++) { int num = rand()%100;//对100取余操作 printf("第%d次随机生成0~100的数: %d ",i+1,num); } printf(" "); return 0; }
#include <iostream> #include <time.h> int main() { srand((unsigned)time(NULL));//srand()就是给rand()提供种子seed for (int i = 0; i < 100; i++) { int num = rand()%100;//对100取余操作 printf("第%d次随机生成0~100的数: %d ",i+1,num); } printf(" "); return 0; }