Two dimensional array counting cards C++
I'm creating a program to tell me how many times I've picked the same card
on an endless deck of all 52 cards So the output would look something like
Clubs : 1 0 0 0 0 1 0 1 0 0 2 0 1
Diamonds : 0 2 1 1 1 0 0 0 0 0 0 0 0
Hearts : 1 2 0 1 1 0 0 0 0 3 0 1 1
Spades : 1 1 2 1 0 1 0 0 0 0 1 1 0
The problem is: my output is just all 0's for everything.
Here's some code for it:
const string rank[] = { "Ace", "2", "3", "4", "5", "6", "7",
"8", "9", "10", "Jack", "Queen", "King" };
const string suit[] = { "Clubs", "Diamonds", "Hearts", "Spades" };
for (int x=0; x < 4; x++)
{
for (int y=0; y <13; y++)
{
if ((suit[x] ==word1) && (rank[y] ==word2)) //assuming word1
and word2 are a randomly chosen mix (example being ace of
clubs, 2 of diamonds, 3 of spades, etc)
{
deck[x][y]+=1;
}
}
}
I think the problem lies within the the if statement
No comments:
Post a Comment