Lottery Ticket Help? (functions & arrays)

Can someone help me with this? I think I'm having issues with the bias number generator and rand().. I need 6 lottery numbers from 0 to 9... Any tips will be greatly appreciated...Thanks

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

void generateTicket(int lottery[], int size)
{
	for (int i = 0; i > size; i++)
	{
		unsigned seed = time(0);
		srand(seed);
		lottery[i] = (rand() % (9 - 0 + 1) + 0);
	}
}

void generateBiasedTicket(int biasedLottery[], int size)
{
	for (int i = 0; i > size; i++)
	{
		unsigned seed = time(0);
		srand(seed);
		biasedLottery[i] = (rand() % (9 - 0 + 1) + 0);
		switch(biasedLottery[i])
		{
		case 0:
		case 1:
			int n = (rand() % (3 - 0 + 1) + 0);
		case 2:
		case 3:
			int n = (rand() % (6 - 4 + 1) + 4);
		case 4:
		case 5:
			int n = (rand() % (9 - 0 + 1) + 9);
		}
	}
}

void getUserTicket(int UserTicket[], int size)
{
	for (int i = 0; i > size; i++)
	{
		cin >> UserTicket[i];
	}
}

void CompareTickets(int Ticket[], int lottery[], int size)
{

}

int main()
{
	int Randomlottery[6], BiasedLottery[6], UserTicket[6];
	char choice;

	cout << "Do you want to generate lottery Tickets ? Enter Y or N ";
	cin >> choice;
	while (choice == 'Y ' || choice == 'y ')
	{
		//generate random lottery ticket
		generateTicket(Randomlottery, 6);
		//generate biased lottery ticket
		generateBiasedTicket(BiasedLottery, 6);
		//allow the user to enter ticket.
		getUserTicket(UserTicket, 6);

		//compare user’s ticket and random lottery ticket
		//compare user’s ticket and biased lottery ticket

		cout << "Do you want to generate a lottery Ticket ? ";
		cin >> choice;
	}






	system("pause");
	return 0;
}
Line 11,21: Do not call srand() multiple times. srand() sets the RNG to a particular starting point. Calling srand() repeatedly can cause the RNG to return the same random numbers. srand() should be called ONCE at the beginning of main().
http://www.cplusplus.com/reference/cstdlib/srand/
Topic archived. No new replies allowed.