用户通过键盘输入一串字符,该字符串以回车键结束输入,

2020-06-12 财经 115阅读
#include
int main()
{
int alph = 0, num = 0, space = 0, other = 0;
char c;
while ((c=getchar()) != '\n')
{
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
alph ++;
else if (c >= '0' && c <= '9')
num ++;
else if (c == ' ')
space ++;
else
other ++;
}
printf("1001 static:\n");
printf("There are %d Alphabet Characters.\n", alph);
printf("There are %d Number Characters.\n", num);
printf("There are %d Space Characters.\n", space);
printf("There are %d Other Characters.\n", other);
return 0;
}
有问题再联系~
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com