求C语言程序设计高手解答考试题~~在线等,急需,谢谢

2025-02-27 03:51:58
推荐回答(2个)
回答1:

#include

int main()
{
char ch=NULL;
int big=0,small=0,others=0;
while((ch=getchar())!='#')
{
if(ch>='A'&&ch<='Z') big++;
else if(ch>='a'&&ch<='z') small++;
else if(ch<'0'||ch>'9') others++;
}
printf("bigletter=%d\nsmallletter=%d\nothers=%d\n",big,small,others);
return 0;
}

回答2:

#include
int main(void)
{
char ch;
int lwr=0, uppr=0,other=0;
scanf("%c",&ch);
while(1)
{
scanf("%c",&ch);
if(ch == '#')break;
if(ch >= 'a' && ch <='z')
lwr++;
else if(ch >= 'A' && ch <='Z')
uppr++;
else
other++;
}
printf("%d%d%d",lwr,uppr,other);

}