C++产生N(这里N=100)以内的随机整数的例子:

#include <iostream>
#include <ctime>

using namespace std;

int main()
{	
	srand((int)time(0));  // 产生随机种子,否则每次的随机结果都是一样
	for (int i = 0; i < 10000; i++)
	{	
		cout << rand() % 100 << " ";
	}
	return 0;
}

运行结果:
C++产生N以内的随机整数

相关文章:

  • 2022-12-23
  • 2021-11-22
  • 2021-05-29
猜你喜欢
  • 2022-12-23
  • 2022-02-09
  • 2022-12-23
  • 2021-08-02
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案