记牌器程序

下面是记牌器的程序,输入X时终止程序。

#include

#include

int main ()

{

 charcard_name[3];

 intcount =0;

 do {

      puts("输入牌名:");

      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("dataerror");

                           continue;

                      }

        }

       if(val>2&&val<7){

              count++;

       }elseif(val==10){

              count--;

       }

       printf("当前计数:%i\n",count);

 }while (card_name[0]!='X'); 

 return 0;

}

你可能感兴趣的:(记牌器程序)