/*编程:有一篇文章,共有3行文字,每行有80个字符。
*要求分别统计出其中英文大写字母、小写字母、数字、空格以及其他字符的个数。
*/
#include
int main(void)
{
char str[3][81];
int capital = 0, lowercase = 0, space = 0, number = 0, other = 0;
int i, j;
puts("请输入你的文章(三个字符串): ");
for(i = 0; i < 3; i++)
gets(str[i]);
for(i = 0; i < 3; i++)
printf("%s\n", str[i]);
for(i = 0; i < 3; i++)
{
for(j = 0; j != '\0'; j++)
{
if(str[i][j] >= 'A' && str[i][j] <= 'Z')
capital++;
else if(str[i][j] >= 'a' && str[i][j] <= 'z')
lowercase++;
else if(str[i][j] == ' ')
space++;
else if(str[i][j] >= '0' && str[i][j] <= '9')
number++;
else
other++;
}
}
printf("该文章的大写字母有 %d 个。 \n", capital);
printf("该文章的小写字母有 %d 个。\n", lowercase);
printf("该文章的阿拉伯数字有 %d 个。 \n", number);
printf("该文章的空格有 %d 个。 \n", space);
printf("该文章的其他字符有 %d 个。 \n", other);
return 0;
}