请编写程序,实现以下功能:
输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。
有没有人会,帮忙编写一个c语言程序,语言写一个后缀为.c的c语言程序
请编写程序,实现以下功能:
输入一行字符,分别统计出其中英文字母、空格、数字和其它字符的个数。
有没有人会,帮忙编写一个c语言程序,语言写一个后缀为.c的c语言程序
供参考:
#include <stdio.h>
#include <ctype.h>
int main()
{
char str[128];
int i = 0, letter = 0, space = 0, num = 0, other = 0;
gets(str);
while (str[i]) {
if (isalpha(str[i])) letter++;
else if (isspace(str[i])) space++;
else if (isdigit(str[i])) num++;
else other++;
i++;
}
printf("Letter:%d ,Space:%d ,Num:%d ,Other:%d", letter, space, num, other);
return 0;
}