fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. bool is_vowel(const char c)
  7. {
  8. return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
  9. }
  10.  
  11. int main()
  12. {
  13. string word, oword;
  14. cin >> word;
  15.  
  16. char prev = 'b'; // must be initialized to an arbitrary consonant, otherwise if the first letter is a vowel, it won't be detected.
  17. for (char c : word)
  18. {
  19. if (!is_vowel(prev) && is_vowel(c))
  20. oword += "opp"; // transition detected
  21. oword += prev = c;
  22. }
  23.  
  24. cout << oword;
  25.  
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0.01s 5528KB
stdin
team
stdout
toppeam