输入一句话,无标点符号,空格分隔,输出单词the出现的次数,用c语言实现
例如输入 the world the big输出2
供参考:
#include <stdio.h>
#include <string.h>
int main()
{
int count = 0;
char str[1000], * word = "the";
gets(str);
char* p = strtok(str, " ");
while (p != NULL) {
if (!strcmp(p, word))
count++;
p = strtok(NULL, " ");
}
printf("%d", count);
return 0;
}
这个问题你交给GPT更好的,能够回答这个问题了就