输入任意一串字符(以#结束),分别统计出大写字母,小写字母,以及其他字符的个数,并将结果输出。

【C语言】写一个主函数、输入任意一串字符(以#结束),分别统计出大写字母,小写字母,以及其他字符的个数,并将结果输出。

#include "stdio.h"
void main()
{
char str;
int up=0,low=0,other=0;
printf("please input the string\n");
do{
scanf("%c",&str);
if(str >='a' && str<='z')
low++;
else if(str>='A' && str<='Z')
up++;
else
other++;
}
while(str!='#');
--other;//uncount the char '#'

printf("the count of Capital is %d\n",up);
printf("the count of lowercase is %d\n",low);
printf("the count of other letter is %d\n",other);
}
这些都是很简单的,要自己努力。。你自己把这个东西改成函数吧。
温馨提示:答案为网友推荐,仅供参考
相似回答