全心思齐网

C语言,任意输入十个字符,统计其中数字,字母,空格及回车,其他字符的个数?

参考下面的代码:

#include<stdio.h>

int main()

{

char c;

int num=0,lett=0,bar=0,others=0;

scanf("%c",&c);

while(c!='#')

{

if(c==' ') bar++;

else if(c>='0'&&c<='9') num++;

else if(c>='a'&&c<='z' || c>='A'&&c<='Z') lett++;

else others++;

scanf("%c",&c);

}

return 0;

}

匿名回答于2020-08-10 19:11:37


相关知识问答