Created
July 8, 2014 02:43
-
-
Save LBRapid/a21977fadc5379047864 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main() | |
{ | |
char card_name[3]; | |
int count = 0; | |
while (card_name[0] != 'X') { | |
puts("Enter the card name: "); | |
scanf("%2s", card_name); | |
int val = 0; | |
switch(card_name[0]) { | |
case 'K': | |
case 'Q': | |
case 'J': | |
val = 10; | |
break; | |
case 'A': | |
val = 11; | |
break; | |
case 'X': | |
continue; | |
default: | |
val = atoi(card_name); | |
if ((val < 1) || (val > 10)) { | |
puts("I don't understand that value!"); | |
continue; | |
} | |
} | |
if ((val > 2) && (val < 7)) { | |
count++; | |
} else if (val == 10) { | |
count--; | |
} | |
printf("Current count: %i\n", count); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment