c++随机数 基础的

 int random=rand()%60即为0-59的范围

若rand()%60+40即为40-99的范围;但似乎是假随机,得用随机数种子。

再把random赋值给那个想要变成随机数的变量

先包含头文件#<ctime>

然后再main函数中种种子  srand((unsigned int)time(NULL));

posted @ 2020-10-15 17:18  觖泽  阅读(114)  评论(0编辑  收藏  举报