从键盘输入的字符串由英文的句子组成(if you are doing your best, you will not have to worry about.)。(注意:单词之间可能不止一个空格)
完成:对输入字符串进行英文字母个数,空格个数,英文单词个数的统计,并且显示统计结果。
用devc++平台编写
这种字符串的c语言这种字符串的c语言
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
树下等苹果 2022-05-11 17:04关注#include<stdio.h> #include<string.h> int main() { void number(char *p); char str[100]; gets(str); number(str); return 0; } void number(char* p) { int letter=0,word=1,space=0; while (*p != '\0') //字符串的结束符号位"\0" { if (('A' <= *p) && (*p <= 'z')) letter++; else if (*p == ' ') { space++; word++; } p++; } printf("字母有:%d个﹐空格有:%d,单词有:%d",letter,space,word); }本回答被题主选为最佳回答 , 对您是否有帮助呢?评论 打赏 举报解决 1无用