安全问答

安全问答是一个知识全球问答,包含丰富的问答知识

首页 常规 游戏 娱乐 科技 程序员

C语言统计单词个数:输入一行英文字符,统计单词数量

  • 日期: 2027-07-14
  • 标签: 常规

#include <stdio.h> #include <string.h>

int main() { char str[100]; int count = 0;

printf('Enter a string:');
fgets(str, sizeof(str), stdin);

for (int i = 0; i < strlen(str); i++) {
    if (str[i] == ' ') {
        count++;
    }
}

printf('%d', count + 1);

return 0;

}


原文地址: https://www.cveoy.top/t/topic/piln 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录

  • 上一篇: 采油机械设备管理与维护:提升效率、安全和环保的关键
  • 下一篇: MPA研究生入学学习心得:收获与成长

© 2019 • 2025 - 安全问答 站长邮箱:wxgpt@qq.com    ICP备案/许可证号:豫ICP备2024104334号-2