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
|
#include <cstdlib>
#include <iostream>
#define MAX_CARDS 13
using namespace std;
int getCardValue( string s );
int main(int argc, char *argv[])
{
string userInput = "";
cin >> userInput;
cout << getCardValue(userInput) << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
int getCardValue( string s )
{
int value = 0;
string names[] = {"2","3","4","5","6","7","8",
"9","10","J","Q","K","A"};
int values[] = {2,3,4,5,6,7,8,9,10,10,10,10,1};
for( int i = 0; i < MAX_CARDS; i++)
{
if( s == names[i])
{
value = values[i];
}
}
return value;
}
|