次の文字列を使用します。
asking a question is easy
whileループが欲しい
- 最初の単語を取る
asking
, - 関数でそれについて何かをチェックし、
- それから次の単語に行きます
a
- など、文字列の最後まで
単語は、1 つ以上のスペースで区切ることができます。
編集:
説明するとき、私は実際に間違いを犯したと思います。ここで私が取り組んできたこと:
int main()
{
cout<<"string="; gets(string);
cout<<"template="; cin>>template;
while (i<strlen(string))
{
k=0;
while (string[i]!=' ')
{
word[k]=string[i];
i++; k++;
}
if (function(string,word)==1) count++;
while (i<strlen(s) && string[i]==' ')
i++;
}
cout <<"count="<<count;
}
学校と同じように、古い/基本的な C++ に固執したいと思います。