hi guys sup....
well i have to make this poker game right let me first post the code..
okay .So i have to modify the programm so it should show only 5 cards ..i can do that its easy but the problem is the question says i should print out if there is a pair of suits or more... okay i tried a brute force method but it dint work let me give u an example...Code:#include <stdio.h> #include <stdlib.h> #include <time.h> void shuffle( int [][ 13 ] ); void deal( const int [][ 13 ], const char *[], const char *[] ); int main() { const char *suit[ 4 ] = { "Hearts", "Diamonds", "Clubs", "Spades" }; const char *face[ 13 ] = { "Ace", "Deuce", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King" }; int deck[ 4 ][ 13 ] = { 0 }; srand( time( 0 ) ); shuffle( deck ); deal( deck, face, suit ); return 0; } void shuffle( int wDeck[][ 13 ] ) { int row, column, card; for ( card = 1; card <= 52; card++ ) { do { row = rand() % 4; column = rand() % 13; } while( wDeck[ row ][ column ] != 0 ); wDeck[ row ][ column ] = card; } } void deal( const int wDeck[][ 13 ], const char *wFace[], const char *wSuit[] ) { int card, row, column; for ( card = 1; card <= 52; card++ ) for ( row = 0; row <= 3; row++ ) for ( column = 0; column <= 12; column++ ) if ( wDeck[ row ][ column ] == card ) printf( "%5s of %-8s%c", wFace[ column ], wSuit[ row ], card % 2 == 0 ? '\n' : '\t' ); }
but the problem is suit[main] is one and suit[sub] is one it will say its a pair right....well is it possible to use continue for it ????....if u guys have a better way i would like to know...thanksCode:for ( cnt_main =0; cnt_main <=4; cnt_main++ ) for ( cnt_sub =0; cnt_sub <=4; cnt_sub++ ) if ( suit[cnt_main] == suit[cnt_sub] ) printf ("You have a pair of %s", suit );
DaIn



LinkBack URL
About LinkBacks



..Well its giving me warning like