/* title: Card Dealing Program coder: aeriqusyairi date:feb5 2012 */ #include<stdio.h> #include<stdlib.h> #include<time.h> void shuffle( int wDeck[][ 13 ] ); void deal( const int wDeck[][ 13 ], const char *wFace[], const char *wSuit[] ); int main(){ const char *suit[ 4 ] = { "Heart", "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 ); system("pause"); 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' ); } } } } }
My C Repository
C How to Program
Sweet thanks to my broski Yusuke Fiz for this Deitel book.
You light up my life dude.
Just another personal public repository.
Friday, March 16, 2012
1) Card Shuffling and Dealing: Card Dealing Program
Simply deals a deck of card :)
Subscribe to:
Post Comments (Atom)
Never thought that they are writing this kind of program for online casino?
ReplyDelete