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
|
#include<iostream>
using namespace std;
enum suits { CLUBS, DIAMONDS, HEARTS, SPADES };
enum cardValues { TWO, THREE, FOUR, FIVE, SIX,
SEVEN, EIGHT, NINE, JACK, QUEEN,
KING, ACE };
struct cards{suits suit;
cardValues card;};
cards deck[52];
cards card1, card2;
void createDeck(cards[]);
void printDeck(cards[]);
void printCard(cards);
void deal(cards[], cards&);
void winner(cards, cards);
int main() {
cout << "ok\n";
createDeck(deck);
printDeck(deck);
system("pause");
return 0;
}
void createDeck(cards deck[52]) {
int i = 0;
for (suits suit = CLUBS; suit <= SPADES; suit = suits(suit + 1)) {
for (cardValues card = TWO; card <= ACE; card = cardValues(card + 1)) {
deck[i].suit = suit;
deck[i].card = card;
i++;
}
}
}
void printDeck(cards deck[52]) {
for (int i = 0; i < 52; i++) {
cout << deck[i].card << " of "
<< deck[i].suit << endl;
}
}
|