May 10, 2012 at 5:54pm UTC
So; I have to determine if there is a) 3 of a kind b)4 of a kind c)straight.
I have put the 7 cards into a 1 dimensional array and sorted them but I also need a case for not being more than 4 cards. I don't need to include suits.
Here is what I have done:
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
include<iostream>
include<ctime>
include<cstdlib>
include<iomanip>
using namespace std;
int main()
{
const int size=7;
int cards[size]={};
const int b=13;
int tem[b]={0};
int a;
int p;
srand(time(0));
for (int i=0; i<10; i++)
{
for (int s=0; s<size; s++)
{ cards[s]=1+rand()%13; }
int i = 0, temp;
while ( i < size )
{
if ( i == 0 || cards[i - 1] <= cards[i] )
i++;
else
{
temp =cards[i];
cards[i] = cards[i - 1];
cards[--i] = temp;
}
}
for (p=0; p<b; p++)
{
tem[p-1]++;
if (tem[p]==3)
for (int m=0; m<size; m++)
cout<<setw(4)<<cards[p]; cout<<"Three of a kind. " ;
cout<<endl;
}
}
system("pause" );
return 0;
}
it does not work though
4 of a kind is about the same as 3 of a kind
no idea for the straight
Last edited on May 10, 2012 at 11:37pm UTC
May 10, 2012 at 8:03pm UTC
Please repost your code using the code tags under format.
May 10, 2012 at 11:30pm UTC
Please properly indent your code so it is readable. Also, fix your includes.
May 11, 2012 at 2:15am UTC
What's the difference between const int and int?