Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int count = 0;
- string word;
- flag=true;
- cout << "Введите слово: "; cin >> word;
- for (int i=0; i<str.length(); i++)
- {
- if (str[i]==word[0])
- for(int k=i, j=0;j<word.length() || k<str.length();k++,j++)
- {
- if(str[k]!=word[j])
- flag=false;
- }
- if (flag==true)
- count++;
- flag=true;
- }
- cout << "Текст содержит " << count << " слов " << word <<"." << endl;
Advertisement
Add Comment
Please, Sign In to add comment