#include <stdio.h> #include <ctype.h>
//输入一行字符,分别统计出其中英文字母,空格,数字和其他字符的个数 void Statistics() { char ch; int alpha=0; int blank=0; int digit=0; int other=0; while((ch=getchar())!='\n')//获取一行的输入 { //if (ch>='a'&&ch<='z'||ch>='A'&&ch<='Z') if(isalpha(ch)) { alpha++; } else if(ch == ' ') { blank++; } else if(isdigit(ch)) { digit++; } else { other++; } } printf("字母个数:%d 空格个数:%d 数字个数:%d 其他字符:%d\n",alpha,blank,digit,other); }