#include <stdio.h>
int main()
{
int i, letter, blank, digit, other;
char ch;
letter = blank = digit = other = 0;
for (i = 0; i < 10; i++)
{
scanf("%c", &ch);
if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
letter++;
else if (ch == ' ' || ch == '\n')
blank++;
else if (ch >= '0' && ch <= '9')
digit++;
else
other++;
}
printf("letter = %d, blank = %d, digit = %d, other = %d", letter, blank, digit, other);
return 0;
}
浙大版《C语言程序设计(第3版)》题目集 练习3-4 统计字符 (15分)
猜你喜欢
转载自blog.csdn.net/qq_44458489/article/details/105281634
今日推荐
周排行