#include <stdio.h> int main() { char s[20]; char num=0; int num_count=0; int space_count=0; int other_count=0; while((num=getchar())!='\n') { if(num>='0'&&num<='9') { num_count++; } else if(num==' ') { space_count++; } else { other_count++; } } printf("num_count=%d\n",num_count); printf("space_count=%d\n",space_count); printf("other_count=%d\n",other_count); return 0; }
【C语言】编写一个程序统计输入字符串中: 各个数字、空白字符、以及其他所有字符出现的次数。
原创安下 ©著作权
文章标签 C语言 编写一个程序统计输入字符串中: 各个数字 文章分类 C/C++ 后端开发
-
【C语言加油站】详细解读字符函数与字符串函数
【C语言加油站】字符函数与字符串函数详细介绍字符函数与字符串函数的相关知识点……
C语言 字符串 字符函数 字符串函数