寻找一串英文里包含多少个指定的单词
输入
word sentence
输出
n
例
输入
cat Acatisonthetable
输出
1
输入
mickey minnieisacutemouse
输出
0
使用函数
寻找一串英文里包含多少个指定的单词
输入
word sentence
输出
n
例
输入
cat Acatisonthetable
输出
1
输入
mickey minnieisacutemouse
输出
0
使用函数
#include<stdio.h>
#include<string.h>
void count_word(char*word, char*sen, int&num)
{
char*keep = (char*)sen;
char*p1;
while (*keep)
{
p1 = (char*)word;
while (*p1&&*keep && !(*p1 - *keep))
{
p1++;
keep++;
}
if (*p1 == '\0')
num++;
else
keep++;
}
}