C语言编程题目啊。。。。。。。。。

来源:百度知道 编辑:UC知道 时间:2024/06/05 12:58:46
11. 输入一字符串,统计其中的字母个数做输出

#include <stdio.h>
#include <string.h>
main()
{
char a[80];
int k=0,i,t;
gets(a);
t=strlen(a);
for(i=0;i<t;i++)
if(a[i]>='a'&&a[i]<='z'||a[i]>='A'&&a[i]<='Z')
k++;
printf("字母个数是:%d",k);
}

#include< stdio.h >

int main( void )
{
int i = 0;
int c;

printf("请输入字符串:");

while( '\n' != ( c = getchar() ) )
{
if( (c <= 'z' && c >= 'a') || (c >= 'A' && c <= 'Z') )
{
++i;
}
}

printf("其中有%d个字母。\n", i);

return ( 0 );
}