输入英文句子统计单词个数c语言

学习 时间:2026-04-04 20:12:13 阅读:5982
输入英文句子统计单词个数c语言输入一个英文句子,单词间用空格隔开.统计单词个数.在dev cpp软件下用.c格式运行.并注明原理.

最佳回答

冷傲的外套

忧虑的故事

2026-04-04 20:12:13

#include "stdio。h"
main()
{
char *s;
int cnt = 0;
printf("please enter the sentence\n");
gets(s);
while(*s)
{
if(*s==' ') cnt++;
s++;
}
printf("the sectence have %d word\n",cnt+1);
}

最新回答共有2条回答

  • 外向的大地
    回复
    2026-04-04 20:12:13

    #include "stdio。h"main(){char *s;int cnt = 0;printf("please enter the sentence\n");gets(s);while(*s){if(*s==' ') cnt++;s++;}printf("the sectence have %d word\n",cnt+1);}

上一篇 宋元时期农耕文化的代表是--族的--?

下一篇 设计家用楼房需要注意什么