似乎用' '表示空格才行
#include <stdio.h>
int main(void)
{
char c;
int blank, digit, letter, other;
int ri, repeat;
scanf("%d", &repeat);
getchar();
for(ri = 1; ri<=repeat; ri++){
c = getchar();
/*-输入一个正整数 repeat (0<repeat<10),做 repeat 次下列运算:
输入一行字符,以回车结束,统计出其中的英文字母、空格、数字和其他字符的个数。
输入输出示例:括号内是说明
输入
2 (repeat=2)
Reold building room 123.
Programming is fun!
输出
letter = 17, blank = 3, digit = 3, other = 1 ("Reold building room 123."中的英文字母、空格、数字和其他字符的个数)
letter = 16, blank = 2, digit = 0, other = 1 ("Programming is fun!"中的英文字母、空格、数字和其他字符的个数)
*/blank=digit = letter = other =0;
while(c!='\n'){
if( ('a'<=c && c <='z')||('A'<=c && c <='Z'))
letter++;
else if( c=='\t')
blank++;
else if( '0'<=c&&'9'>=c)
digit++;
else other++;
c=getchar();
}
printf("letter = %d, blank = %d, digit = %d, other = %d\n", letter, blank, digit, other);
}
}