#include<stdio.h>
int main()
{
int letters = 0, numbers = 0, spaces = 0, others = 0;
char a;
while ((a = getchar()) != '\n')
{
if ((a >= 'a' && a <= 'z') || (a >= 'A' && a <= 'Z'))
letters++;
else if (a >= '0' && a <= '9')
numbers++;
else if (a ==' ')
spaces++;
else
others++;
}
printf("字母=%d 数字=%d 空格=%d 其他=%d", letters, numbers, spaces, others);
return 0;
}
(不知道为什么,我设置的封面看不到😔)