asdfg0998

Untitled

Jun 16th, 2025
405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1.     unordered_set<char> vowels = {'a', 'e', 'i', 'o', 'u'};
  2.     int count = 0;
  3.  
  4.     for (int i = 0; i + 2 < text.length(); ++i) {
  5.         int vowelCount = 0;
  6.  
  7.         for (int j = i; j < i + 3; ++j) {
  8.             if (vowels.count(text[j])) {
  9.                 vowelCount++;
  10.             }
  11.         }
  12.  
  13.         if (vowelCount == 2) {
  14.             count++;
  15.         }
  16.     }
  17.  
  18.     return count;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment