1 int main() 2 { 3 // 算牌器 4 char char_name[3]; 5 int count = 0; 6 7 do { 8 9 printf("请输入牌名: "); 10 scanf("%2s",char_name); 11 int value = 0; 12 switch (char_name[0]) { 13 case 'J': 14 case 'Q': 15 case 'K': 16 value = 10; 17 break; 18 case 'A': 19 value = 11; 20 break; 21 case 'X': 22 continue; 23 default: 24 value = atoi(char_name); 25 break; 26 } 27 28 if (value < 1 || value > 10) { 29 30 puts("我无法理解这个值"); 31 continue; 32 } 33 34 if (value > 2 && value < 7) { 35 count++; 36 } 37 else if (value == 10) { 38 count--; 39 } 40 41 printf("计数器的值是: %i ",count); 42 43 } while (char_name[0] != 'X'); 44 return 0; 45 }