// Programmieren 1, Praktikum 5, Aufgabe 1 // Sven Eisenhauer // 16.12.2004 // // file: main.cpp // // purpose: Shuffle a standard deck of 52 cards and deal them // #include using std::cin; using std::cout; using std::endl; using std::left; using std::right; #include using std::setprecision; using std::setw; // contains function prototypes for functions srand and rand #include #include const int maxColumns=13; const int maxRows=4; const int maxCards=52; // prototypes void shuffle( int [][ maxColumns ] ); void deal( const int [][ maxColumns ], const char *[], const char *[] ); int main() { // initialize suit array const char *suit[ 4 ] = { "Hearts", "Diamonds", "Clubs", "Spades" }; // initialize face array const char *face[ 13 ] = { "Ace", "Deuce", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King" }; // initialize deck array int deck[ maxRows ][ maxColumns ] = { { 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,43,44,45,46,47,48,49,50,51,52 } }; srand( time( 0 ) ); // seed random number generator shuffle( deck ); deal( deck, face, suit ); return 0; // indicates successful termination } // end main // shuffle cards in deck void shuffle( int wDeck[][ 13 ] ) { int temp=0; int randRow, randCol; for (int column=0;column