C/C++ 函数(统计英文字母的个数)

题目描述

统计每一行中英文字母的个数。

输入

有多组数据,每组一行。

输出

每行中英文字母的个数。

样例输入

AB1C2 Dx1yhz
qweqeABC;DOA

样例输出

8
11
#include
#include
int fun(char p[])
{
    int i,count=0;
    for(i=0; p[i]!=0; i++)
    {
       if(p[i]>='a'&&p[i]<='z')
         {
             count++;
         }
          if(p[i]>='A'&&p[i]<='Z')
         {
             count++;
		  }
	}
	return count;
}
void main()
{
	char p[100];
	int s;
	while(gets(p))
	{
		s=fun(p);
		printf("%d\n",s);
	}
}


 

你可能感兴趣的:(rwoj-AC)