C 统计 符号出现的次数 ,字母,空格,数字,标点
作者:互联网
统计 符号出现的次数 ,字母,空格,数字,标点
#include <stdio.h>
#include <malloc.h>
int main()
{
char c;
int letters = 0, space = 0, digit = 0, others = 0;
while ((c = getchar()) != '\n')
{
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
letters++;
else if (c == ' ')
space++;
else if (c >= '0' && c <= '9')
digit++;
else
others++;
}
printf("%d %d %d %d",letters,space,digit,others);
return 0;
}
标签:int,字母,标点,空格,&&,include 来源: https://blog.csdn.net/laocooon/article/details/122134081