C实例---键盘输入字符串,统计空格
2017-01-04 17:41
197 查看
代码:
运行效果:
#include <stdio.h> int Num(const char *s) { int count = 0; while (*s != '\0') if (*s ++ == ' ') count ++; return count; } int main () { char s[200]; scanf("%[^\n]",s); //gets(s); //有警告 printf("%d\n", Num(s)); return 0; }
运行效果:
相关文章推荐
- C实例----删除键盘输入字符串的所有空格
- 编写一函数,由实参传来一个字符串,统计此字符串中字母、数字、空格和其它字符的个数,在主函数中输入字符串以及输出上述结果。 只要结果,别输出什么提示信息。
- 1~ 从键盘输入一行字符,统计其中的单词个数。此处认为一个单词是介于空格之间的字符序列。
- Linux-C基础知识学习:C语言作业-从键盘输入一行字符,统计其中有多少个字母, 数字,空格(用数组实现,gets)。
- 初学java:从键盘输入字符串,并统计其中数字字符的个数
- 华为机试: 计算字符串的相似度、输入一行字符,分别统计出包含英文字母、空格、数字和其它字符的个数
- 编写一函数,由实参数来一个字符串,统计此字符串中字母、数字、空格和其它字符的个数,在主函数中输入字符串以及输出上述的结果
- 通过键盘输入100以内正整数的加、减运算式,请编写一个程序输出运算结果字符串。 输入字符串的格式为:“操作数1 运算符 操作数2”,“操作数”与“运算符”之间以一个空格隔开。 补充说明: 1、操作数为
- 编写一函数,由实参传来一个字符串,统计此字符串中字母、数字、空格和其它字符的个数,在主函数中输入字符串以及输出上述结果。 只要结果,别输出什么提示信息。
- 编写一个函数,从实参传来一个字符串,统计其中字母,数字,空格和其他字符的个数,在主函数中输入字符串以及输出上述的结果
- 习题 7.9 编写一个函数,由实参传来一个字符串,统计此字符串中字母、数字、空格、和其他字符的个数,在主函数中输入字符串以及输出上述的结果。
- java统计字符串中的字符重复的次数和和出现次数 实例(输入字符串)
- 试编写一个程序,输入一个字符串,统计其中有多少各单词?单词之间用空格分开
- 编写一个函数,由实参传来一个字符串,统计此字符串中字母,数字,空格,和其他字符的个数,在主函数中输入字符串以及输出上述统计的结果。再考虑将算的的结果放在一个数组中
- (c++)编写一函数,由实参传来一个字符串,统计此字符串中字母、数字、空格和其它字符的个数,在主函数中输入字符串以及输出上述结果。 只要结果,别输出什么提示信息。
- c语言从键盘上输入一串字符串,统计这个字符串中存在的数字和字母的总数
- 输入一行字符串,统计其中有多少个单词,单词之间用一个或者多个空格分隔开
- 输入字符串,统计其中数字,空格和其他字符的个数
- 对于给定的一个字符串,统计其中数字字符出现的次数。输入数据有多行,第一行是一个整数n,表示测试实例的个数,后面跟着n行,每行包括一个由字母和数字组成的字符串。
- 经典map集合问题,黑马作业题,1.利用键盘录入,输入一个字符串,.统计该字符串中各个字符的数量(提示:字符不用排序)