Counter in Array / Comparison?

I am working on a ''dice'' game. The data for my program looks like three columns, one per each roll. Assume 5 different players will each get 2 rolls, so the data is like a 5x2 grid containing a "string" (not an integer) spelling out the number in the range 1-6.


The stipulation of this game is that if a player rolls a "unique" number, they automatically win the game. How would I implement this function?


I don't have any real code beyond gathering the "roll" data. I am thinking of using nested for loops. I do not know what type of function to use, however.
This code was mostly made by my friend but maby you can get some ideas from it.
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#include <iostream>
#include <time.h>
#include <cstdlib>
#include <windows.h>
#include <string>
using namespace std;
void one();
void two();
void three();
void four();
void five();
void six();
//Declare Functions used
int main()
{
short unsigned int score = 0;
short unsigned int compScore = 0;
short unsigned int num = 0;
short unsigned int num2 = 0;
short unsigned int compNum = 0;
short unsigned int compNum2 = 0;
short unsigned int sum = 0;
short unsigned int compSum = 0;
string letter;
//Declare Variables
srand(time(NULL));
//Initialize random number generator
system("title Hello");
//system ("color 48");
while (letter != "q")
{
    cout << "Your Score: " << score << endl;
    cout << "computer's Score: " << compScore << endl << endl;
    cout << "Press r to roll or q to quit: ";
    getline (cin,letter);
    num = 1 + rand() % (6 - 1 + 1);
    num2 = 1 + rand() % (6 - 1 + 1);
    compNum = 1 + rand() % (6 - 1 + 1);
    compNum2 = 1 + rand() % (6 - 1 + 1);
    
    //Random numbers
    
    sum = num + num2;
    compSum = compNum + compNum2;
    
    //Calculate Sums
    if (letter == "q")
        break;
            if (letter == "t"){
        score += 500;
    }
    if (letter == "o")
    {                    
       system("start iexplore www.addictinggames.com");
       }
    if (letter != "r")
    {
        system("cls");
        continue;
    }
    
    switch (num)
    {
        case 1:
                one();
                break;
        case 2:
                two();
                break;
        case 3:
                three();
                break;
        case 4:
                four();
                break;
        case 5:
                five();
                break;
        case 6:
                six();
                break;
        default:
                cout << "Error...";
                break;
    } //end switch
    
    switch (num2)
    {
        case 1:
                one();
                break;
        case 2:
                two();
                break;
        case 3:
                three();
                break;
        case 4:
                four();
                break;
        case 5:
                five();
                break;
        case 6:
                six();
                break;
        default:
                cout << "Error...";
                break;
    } //end switch
        
    cout << endl << "Yours: " << num << ", " << num2 << endl;
    cout << "Computer's: " << compNum << ", " << compNum2 << "\n\n";
    
    //Display dice and numbers
    
    if (sum > compSum)
    {
        cout << "You won!!" << endl << endl;
        score++;
    }
    else
    {
        compScore++;
        cout << "you lost..." << endl << endl;
    }
    
    //Calculate score
    
    system("pause");
    system("cls");
    
    if (score == 12)
    {
        MessageBox(0, "You Won!!!", "Results:", MB_ICONEXCLAMATION);
        break;
    }
    if (compScore == 12)
    {
        MessageBox(0, "You lost...", "Results:", MB_ICONEXCLAMATION);
        break;    
    }
}
return 0;
}

void one()
{
     system ("color 9");
cout << " -----" << endl;
cout << "|     |" << endl;
cout << "|  O  |" << endl;
cout << "|     |" << endl;
cout <<  " -----" << endl;
}
void two()
{
     system ("color 8");
cout << " -----" << endl;
cout << "|    O|" << endl;
cout << "|     |" << endl;
cout << "|O    |" << endl;
cout <<  " -----" << endl;
}
void three()
{
cout << " -----" << endl;
cout << "|    O|" << endl;
cout << "|  O  |" << endl;
cout << "|O    |" << endl;
cout <<  " -----" << endl;
}
void four()
{
cout << " -----" << endl;
cout << "|O   O|" << endl;
cout << "|     |" << endl;
cout << "|O   O|" << endl;
cout <<  " -----" << endl;
}
void five()
{
cout << " -----" << endl;
cout << "|O   O|" << endl;
cout << "|  O  |" << endl;
cout << "|O   O|" << endl;
cout <<  " -----" << endl;
}
void six()
{
cout << " -----" << endl;
cout << "|O   O|" << endl;
cout << "|O   O|" << endl;
cout << "|O   O|" << endl;
cout <<  " -----" << endl;
}
Topic archived. No new replies allowed.