记录示例,留作自用

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main(void)
{
    //设置当前时间戳作为rand的种子
    srand((unsigned int)time(NULL));
    //生成随机数
    int rnd = rand();
    printf("生成了随机数: %d\n", rnd);
    return 0;
}

参考1: Linux C语言生成随机数
参考2:c语言产生随机数的方法

相关文章:

  • 2022-01-22
  • 2022-12-23
  • 2021-10-11
  • 2021-10-01
  • 2021-10-01
  • 2021-05-07
  • 2022-12-23
  • 2022-01-22
猜你喜欢
  • 2021-10-01
  • 2021-10-01
  • 2021-05-13
  • 2022-12-23
  • 2021-10-01
  • 2021-10-01
  • 2021-10-01
相关资源
相似解决方案