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
|
#include <stdlib.h>
#include <iostream>
#include <ctime>
#include <algorithm>
using namespace std;
const char* FaceString[13] = {"Ace", "2", "3", "4",
"5", "6", "7", "8",
"9", "10", "Jack", "Queen", "King"};
const char* SuitString[4] = {"Spades", "Hearts", "Diamonds", "Clubs"};
string player1[5];
class Card
{
public:
int face;
int suit;
void toString() {
cout<<FaceString[face]<<" of "<<SuitString[suit]<<endl;
}
};
int main()
{ char *getCard;
getCard = new char;
// Create a deck of cards
Card deck[52];
for (int i = 0; i < 52; i++) {
deck[i].face = i % 13;
deck[i].suit = i % 4;
}
// Shuffle
srand (unsigned(time(0)));
random_shuffle(&deck[0], (&deck[0]+52));
// Display cards
for (int j = 0; j < 52; j++) {
cout<< "Card_" << (j+1) << ": ";
deck[j].toString();
}
for (int j = 0; j < 5; j++) {
getCard=deck[j].toString();
}
return 0;
}
|