我的C/C++学习----随机数
#include <stdio.h> #include <stdlib.h> #include <time.h> void main() { float s; srand((int)time(0)); s = (float)rand() / RAND_MAX; s = 3 + (5 - 3) * s; //[3,5]之间float数 [3,5]之间整数 s = rand() % 2 + 4 printf("%f\n", s); while (1); }
为什么要奋斗?因为我有梦想!为了诗和远方!