对于随机数的产生,涉及到两个函数:rand()srand()

如下例子:

#include<iostream>
#include<ctime>
#include<cstdlib>

using namespace std;
int main()
{
    srand( (unsigned)time(NULL) );  //设置种子
    cout << rand() << endl;  //生成随机数
    return 0;
}

相关文章:

  • 2021-12-23
  • 2021-10-05
  • 2021-08-23
  • 2022-01-06
  • 2021-10-11
  • 2021-11-06
猜你喜欢
  • 2022-01-29
  • 2021-06-01
  • 2022-12-23
  • 2022-12-23
  • 2021-06-29
  • 2021-11-15
  • 2022-01-05
相关资源
相似解决方案