求C语言题目:从键盘输入一个字符串,输出小写字母并统计个数....

有没有人在啊,想请讲解下,求C语言题目:从键盘输入一个字符串,输出小写字母并统计个数....
最新回答
猫腻仙女

2025-02-25 00:07:11

#include <stdio.h>

int main(void)
{
char s[128];
int i = 0, sum = 0;

printf("please input a string\n");

while (1)
{
scanf("%c", &s[i]);
if ('\n' == s[i]) break;
i++;
}

for (i = 0; s[i]; i++)
{
if (s[i] >= 'a' && s[i] <= 'z')
{
printf("%c ", s[i]);
sum++;
}
}

printf("\nthe count of lower letter is %d\n", sum);
return 0;
}
盏茶作酒

2025-02-25 00:05:24

#include"stdio.h"
main()
{

char s[];
int i,k=0;
gets(s);
for(i=0;s[i];i++)
if(s[i]>='a'&&s[i]<='z')
{
k++;
printf("%c",s[i]);
}
printf("\nlowercount=%d\n",k);

getchar();
}
听属于俩人的歌

2025-02-25 03:04:15

#include <stdio.h>
main()
{ int ch,i=0;
while((ch=getchar())!='\n')
if(ch>='a'&&ch<='z'&&++i) putchar(ch);
printf("\n\tcount:%d\n",i);
}
烟花○的眼泪

2025-02-25 02:00:09

#include <stdio.h>
void main()
{
char s[81];
int i,k=0;
gets(s);
for(i=0;s[i];i++)
if(s[i]>='a'&&s[i]<='z')
{
k++;
printf("%c",s[i]);
}
printf("\nlowercount=%d\n",k);
}