标签:random 初始化 随机 clu for ble and null div
#include <stdio.h> #include <stdlib.h> #include <time.h> int main(int argc, char** argv) { int n = 300000000; double U; int random_num; srand(time(NULL)); //初始化随机数种子 for (int i = 0; i < 10; i++) { U = (double)rand() / RAND_MAX; //生成[0,1]之间的随机数 random_num = (int)((n - 1)*U + 0.5); //生成[0,n-1]之间的随机数 printf("%d ", random_num); } return 0; }
标签:random 初始化 随机 clu for ble and null div
原文地址:https://www.cnblogs.com/lovebay/p/12369983.html