#include <stdio.h>
#define MAXS 15
void StringCount(char *s);
void ReadString(char *s); /* 由裁判实现,略去不表 */
int main()
{
char s[MAXS];
ReadString(s);
StringCount(s);
return 0;
}
void StringCount(char *s)
{
int big, small, blank, digit, others;
char *p;
big = small = blank = digit = others = 0;
for (p = s; *p; p++)
{
if (*p >= 'A' && *p <= 'Z')
big++;
else if (*p >= 'a' && *p <= 'z')
small++;
else if (*p == ' ')
blank++;
else if (*p >= '0' && *p <= '9')
digit++;
else
others++;
}
printf("%d %d %d %d %d", big, small, blank, digit, others);
}
浙大版《C语言程序设计(第3版)》题目集 习题8-9 分类统计各类字符个数 (15分)
猜你喜欢
转载自blog.csdn.net/qq_44458489/article/details/105376324
今日推荐
周排行