作者:yunjinqi 类别:
日期:2023-06-04 18:52:05
阅读:437 次 消耗积分:0 分
#include <stdio.h>
int main(){
char ch;
int blank_num=0;
int digit_num=0;
int other_num=0;
while (scanf("%c",&ch)!=EOF && ch!='\n'){
// if (j==0 && (ch==' ')){continue;j--;}
switch (ch){
case '0':
digit_num++;
break;
case '1':
digit_num++;
break;
case '2':
digit_num++;
break;
case '3':
digit_num++;
break;
case '4':
digit_num++;
break;
case '5':
digit_num++;
break;
case '6':
digit_num++;
break;
case '7':
digit_num++;
break;
case '8':
digit_num++;
break;
case '9':
digit_num++;
break;
case ' ':
blank_num++;
break;
default :
other_num++;
}
// printf("%d %c letter = %d, blank = %d, digit = %d, other = %d\n",j,ch,letter_num,blank_num,digit_num,other_num);
}
printf("blank = %d, digit = %d, other = %d",blank_num,digit_num,other_num);
return 0;
}