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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
#include "stdafx.h"
#include<iostream>
#include<iomanip>
#include<stdlib.h>
#include<time.h>
void shuffle(int[][13]);
void deal(const int[][13], int[][13]);
int main()
{
using namespace std;
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 };
int handone[4][13] = { 0 };
srand(time(0));
shuffle(deck);
deal(deck,handone);
cin.clear();
cin.ignore(255, '/n');
cin.get();
return 0;
}
void shuffle(int wDeck[][13])
{
int row, column;
for (int 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], int whandone[][13])
{
for (int i = 0; i < 4; i++){
for (int j = 0; j <= 52; j++){
switch (wDeck[i][j]){
case 1 :
whandone[i][j] = wDeck[i][j];
break;
case 2 :
whandone[i][j] = wDeck[i][j];
break;
case 3 :
whandone[i][j] = wDeck[i][j];
break;
case 4 :
whandone[i][j] = wDeck[i][j];
break;
case 5 :
whandone[i][j] = wDeck[i][j];
break;
default:
break;
}
}
}
}
| |