问题描述
程序代码
#include <stdio.h>
#include <stdlib.h>
/*
*csdn学院--2016级
*目的:让代码见证成长(作为一个初学的菜鸟,如
*大家有发现错误,欢迎指正!)
*文件名称:Myfun69.c
*作者:小臣小仁
完成日期:2016年12月7日
*/
int main()
{
char ch;
int a=0,b=0,c=0;
while((ch=getchar())!='\n')
{
if(ch==' ')
a++;
else if(ch>='0'&&ch<='9')
b++;
else if((ch>='a'&&ch<='z')||(ch>='A'&&ch<='Z'))
c++;
}
printf("空格:%d 数字:%d 字母:%d\n",a,b,c);
return 0;
}
输出结果
知识点总结
通过找到字符对应的ASCLL码,然后进行统计,最后输出
心得体会
知道了A~Z的ASCLL为65~90,a~z的ASCLL为97~122