Generating Random Numbers

Okay so, i'm trying to generate 3 random numbers within the range of 2 and 7, and then have them displayed as separate values, but have no idea how to do it. I understand the general seeding of "srand(time(0);" but need abit more depth to it.
http://www.cplusplus.com/reference/cstdlib/rand/?kw=rand

That should help. Post any code you have for more help.
Here is a modern c++ approach.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <random>

int main()
{
	std::random_device rnd;
	std::mt19937 eng(rnd());
	std::uniform_int_distribution<> range(2, 7);

	for (int i = 0; i < 3; i++)
	{
		std::cout << range(eng) << ' ';
	}

	system("PAUSE");
	return 0;
}


source: http://stackoverflow.com/questions/7560114/random-number-c-in-some-range
Wow thank you so much!
Do you by chance know how to make 3 winning conditions from the randomly generated numbers?

E.g. "If all 3 numbers are same" - Winning Condition
"If 2 numbers are same" - Winning Condition
Topic archived. No new replies allowed.