Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Щеглов В.А. 19ВИ1
- #include <string>
- #include <vector>
- #include <iostream>
- #include <sstream>
- using namespace std;
- int counter(string S, string S1)
- {
- int count = 0;
- string::size_type position = 0;
- while ((position = S.find(S1, position)) != string::npos) {
- count++;
- position++;
- }
- return count;
- };
- int word_count(string strings)
- {
- istringstream split(strings);
- vector<string> tokens;
- char split_char = ' ';
- for (string each; getline(split, each, split_char); tokens.push_back(each));
- int count = 0;
- for(auto& s: tokens) {
- if (counter(s, "А") == 3) {
- count += 1;
- };
- };
- return count;
- }
- int main()
- {
- setlocale(LC_ALL, "Russian");
- cout << "Enter string s: ";
- string s;
- getline(cin, s);
- cout << "Completed string s: " << s << endl;
- cout << "Count of words with \"AAA\": " << word_count(s);
- }
Advertisement
Add Comment
Please, Sign In to add comment