[C]字符统计

C语言统计英文字母、空格、数字和其它字符的数目

  #define _CRT_SECURE_NO_WARNINGS 1
    
    #include <stdio.h>
    
    int main()
    {
    	char c;
    	int letters = 0,
    		space = 0,
    		digit = 0,
    		others = 0;
    	printf("请输入字符串>:");
    	while((c=getchar())!='\n')
    	{
    		if(c>='a'&&c<='z'||c>='A'&&c<='Z')
    			letters++;
    		else if(c == ' ')
    			space++;
    		else if(c>='0'&&c<='9')
    			digit++;
    		else
    			others++;
    	}
    	printf("\n统计结果:\n英文字母=%d\n空格=%d\n整数=%d\n其他字符=%d\n\n", letters, space, digit, others);
    	return 0;
    }

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-08 14:10
点赞 评论 收藏
分享
兄弟们,实习都是在接各种api,该怎么包装简历
仁者伍敌:感觉我自己做小项目也是各种api啊,我要怎么包装简历
点赞 评论 收藏
分享
05-20 21:57
已编辑
门头沟学院 Java
喜欢吃卤蛋的悲伤蛙在...:建信融通没消息吧,我2说有实习挂简历不理了
点赞 评论 收藏
分享
找到实习了&nbsp;给了150一天&nbsp;但是说是低代码&nbsp;值得去吗
码农索隆:是在没实习,可去,待个一两周,不行就润呗
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务