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
|
// Card Deck.cpp : main project file.
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int main()
{
bool ok;
const int ROWS = 4;
int card_face,card_suit,card;
string suits [ROWS] =
{
"Diamonds", "Clubs", "Hearts", "Spades"
};
const int COLS = 13;
string faces [COLS] =
{
"Ace", "Deuce", "Three", "Four", "Five", "Six",
"Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"
};
int deck [ROWS][COLS] =
{
{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}
};
cout << "Enter a number for a card, 1 to 52" << endl;
do
{
ok = false;
cin >> card;
for(int x=0;x<4;x++)
for (int y=0;y<13;y++)
if ( deck[x][y] == card)
ok = true;
if(!ok)
cout << "That card is not in this deck.." << endl << "Enter a different number" << endl;
}while (!ok);
card--;
card_suit = card/13;
card_face = card%13;
cout << "You chose the " << faces[card_face] << " of " << suits[card_suit] << endl;
return 0;
}
|