C++产生N以内的随机整数

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;
}

运行结果:
imglink1

原文地址:https://www.cnblogs.com/charlee44/p/15489650.html