#include<stdio.h>
#include<math.h>
int main(){
char ch;
int letter,blank,digit,other,i;
letter=blank=digit=other=0;
ch=getchar();
for(i=1;i<=10;i++){
if((ch>='A'&&ch<='Z')||(ch>='a'&&ch<='z')){
letter++;
}
else if(ch==' '||ch=='\n'){
blank++;
}
else if(ch>='0'&&ch<='9'){
digit++;
}
else{
other++;
}
ch=getchar();
}
printf("letter = %d, blank = %d, digit = %d, other = %d",letter,blank,digit,other);
return 0;
}
练习3-4 统计字符
最新推荐文章于 2022-12-01 20:20:20 发布