编写程序,设计一个字符数组,输入一个英语句子。统计句子中有多少个小写字母、大写字母、空格及其它字符

来源:百度知道 编辑:UC知道 时间:2024/09/23 06:04:44

#include<stdio.h>
int main(void)
{
int i=0,big=0,small=0,space=0;
char str[100];
gets(str);
while(str[i]!='\0')
{
if(str[i]==' ')
space++;
else if(str[i]>='A'&&str[i]<='Z')
big++;
else
small++;
i++;
}
printf("the minuscule is %d\nthe capitalization is %d\nthe space is %d",small,big,space);
return 0;
}

#include<stdio.h>
void main()
{
char i;
int a=0,b=0,c=0,d=0;
printf("请输入一个英语句子:\n");
i=getchar( );
while(i!='\0')
{ if((i>='a')&&(i<='z')) {a++;}
else if((i>='A')&&(i<='Z')) {b++;}
else if(i==' '){c++;}
else d++;
c=getchar( );
}
printf("小写字母有:%d个\n大写字母:%d个\n空格:%d个\n及其它字符: