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
|
#include <iostream>
#include <ctime>
using namespace std;
void showDeck (int[][9],int,int);
int main(void)
{
int deck[4][9] = {
{0,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}
};
srand(unsigned int(time(NULL)));
showDeck (deck,4,9);
cout <<"\n";
return 0;
}
void showDeck(int deck[][9],int numSuits, int numCardsEachSuit)
{
int i,j;
char suit;
for (j=0; j<numSuits; j++)
{
for (i=0; i<numCardsEachSuit; i++)
{
switch (deck[j][i]/9) {
case 0: suit='S';
break;
case 1: suit='H';
break;
case 2: suit='C';
break;
case 3: suit='D';
break;
};
cout <<suit << deck[j][i]%9+2 <<" ";
};
cout << "\n";
}
return;
};
|