Help with Lotto Program

I'm stuck on this assignment, which is:
Write a program that simulates a lottery. The program should have an array of 5 integers named winningDigits, with a randomly generated number in the range of 0 through 9 for each element in the array. The program should ask the user to enter 5 digits and should store them in a second integer array named player. The program must compare the corresponding elements in the two arrays and count how many digits match. For example, the following shows the winningDigits array and the Player array with sample numbers stored in each. There are two matching digits, elements 2 and 4. Once the user has entered a set of numbers, the program should display the winning digits and the player’s digits and tell how many digits matched.
We're not supposed to use functions.

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
  #include <iostream>
#include <cstdlib>
#include <ctime>
#include <iomanip>
using namespace std;

int main()
{
    int winningDigits[5];
    int playerDigits[5];
    srand((unsigned int)time(0));

    cout << "Enter five numbers: " << endl;
    int num;
    for (int i = 0; i < 5; i++)
    {
        cin >> num;
        if (num < 0 || num > 9)
        {
            cout << "Number must be greater than 0 and less than 9" << endl;
            cout << "Please re-enter number: " << endl;
            cin >> num;
        }
    }
    cout << "The five winning numbers are: " << endl;
        for(int i = 0; i < 5; i++)
        {
            winningDigits[i] = 1 + rand()% 9;
            cout << winningDigits[i] << " ";
        }
    cout << endl;

    int count = 0;
    for (int i = 0; i < 5; i++)
    {
        if (winningDigits[i] == playerDigits[i])
        {
            count = count + 1;
        }
        
    }
    cout << "There are " << count << " matches." << endl;
    return 0;
}


It runs, but it always says there are 0 matches. I also don't know how to print the player digits after the winning digits. Thanks for your help!
There are comments for the major changes made. It may not be outputting what they are looking for in right order but should help you get there.

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
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <iomanip>
using namespace std;

int main()
{
	int winningDigits[5];
	int playerDigits[5];
	srand(time(0));//all you need

	cout << "Enter five numbers: " << endl;
	int num;
	for (int i = 0; i < 5; i++)
	{
		cin >> num;
		while (num < 0 || num > 9)//should use a while to force user to enter correct number
		{
			cout << "Number must be greater than 0 and less than 9" << endl;
			cout << "Please re-enter number: " << endl;
			cin >> num;
		}
		playerDigits[i] = num;//need to add the variable to the array
	}
	cout << "Your numbers are: " << endl;
	for (int i = 0; i < 5; i++)
	{
		cout << playerDigits[i] << " ";
	}
	cout << endl;
	cout << "The five winning numbers are: " << endl;
	for (int i = 0; i < 5; i++)
	{
		winningDigits[i] = rand() % 9 + 1;
		cout << winningDigits[i] << " ";
	}
	cout << endl;
	cout << "Matching digits are: ";
	int count = 0;
	for (int i = 0; i < 5; i++)
	{
		for (int n = 0; n < 5; n++)//need to use a nested for loop
		{
			if (winningDigits[i] == playerDigits[n])
			{
				count += 1;
				cout << playerDigits[n] << " ";
			}
		}

	}
	cout << endl;
	cout << "There are " << count << " matches." << endl;
	return 0;
}
I changed the nested for loop to:
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
for (int i = 0; i < 5; i++)
	{
		for (int n = 0; n < 5; n++)//need to use a nested for loop
		{
			if (winningDigits[0] == playerDigits[0])
			{
				count += 1;
			}
			if (winningDigits[1] == playerDigits[1])
			{
				count += 1;
			}
			if (winningDigits[2] == playerDigits[2])
			{
				count += 1;
			}
			if (winningDigits[3] == playerDigits[3])
			{
				count += 1;
			}
			if (winningDigits[4] == playerDigits[4])
			{
				count += 1;
			}
		}

	}
	cout << endl;
	cout << "There are " << count << " matches." << endl;

but this did not output the correct number of matches. We are supposed to compare each element of the arrays, and even though the elements did not match but another element of the first array matched with a different element from the second array, the program prints that there is a match. I don't know what I'm doing wrong, can you please help? Thank you so much in advance!
Topic archived. No new replies allowed.