Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool check_word(string word, unordered_set <string> dict) {
- int upper_char = 0;
- if (dict.find(word) != dict.end()) {
- return true;
- }
- if (dict.find(word) == dict.end()) {
- const char* char_word = word.c_str();
- for (int i = 0; i < word.length(); i++) {
- if (char_word[i] == toupper(tolower(char_word[i]))) {
- if (char_word[i] == 'A' || char_word[i] == 'E' || char_word[i] == 'I' || char_word[i] == 'O' || char_word[i] == 'U') {
- upper_char++;
- }
- else {
- return false;
- }
- }
- }
- }
- if (upper_char != 1) {
- return false;
- }
- return true;
- }
- void task9() {
- int n;
- cin >> n;
- unordered_set <string> dict;
- for (int i = 0; i < n; i++) {
- string word;
- cin >> word;
- dict.insert(word);
- }
- string sentence;
- std::getline(std::cin, sentence);
- cout << sentence;
- istringstream stream(sentence);
- string word;
- int wrong_words_count = 0;
- while (stream >> word) {
- if (!(check_word(word, dict))) {
- wrong_words_count++;
- }
- }
- cout << wrong_words_count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement