输入一串字符,长度不超过80个,分别统计出其中大写英文字母、空格和其他字符的个数并分别输出。

如题所述

第1个回答  2011-01-07
#include <stdio.h>
#include <string.h>
void main()
{
char str[80];
int i, len, CountBig=0, CountSpace=0, CountOther=0;
gets(str);
len =strlen(str);
for (i=0; i < len; i++)
{
if (str[i] >= 'A' && str[i] <='Z')
{
CountBig++;
}
else if (str[i]==' ')
{
CountSpace++;
}
else
{
CountOther++;
}
}
printf("Big Letter : %d\n", CountBig);
printf("Space Letter : %d\n", CountSpace);
printf("Other Letter : %d\n", CountOther);
}本回答被提问者和网友采纳
第2个回答  2011-01-07
word文档中用“统计”功能,可以统计无限多个字符其中大小写、空格、外来字符、汉语文字……的个数
第3个回答  2011-01-08
楼上的已经给出C语言的算法了,你可以参考一下了
相似回答
大家正在搜