Page 1 of 1

Card game

Posted: Sun Jan 19, 2003 2:24 pm
by Joe
I am doing a card game with 5 cards in my hand.
but when the program should check if i got pair or something i have to write so much.
the five card get numbers between 1 - 52 so it can look like this: card(1) = 3
How do i check if i got pair.......

Re: Card game

Posted: Mon Jan 20, 2003 5:58 am
by frankiebaby
Well, this always works:

PAIR = 0
PAIR_IS = 0

For x = 1 to 5
for y = 1 to 5
 if Card(X) = Card(Y) then
   PAIR = PAIR + 1
   PAIR_IS = CARD(X)
 end if
next
next

if pair then print "YOU HAVE A PAIR OF"; PAIR_IS; "!"

this does not, however, check for two or more pair, but could be easily modified to do so.