Advertisement
BojidarDosev

c++ vectors practise

Jan 4th, 2024
978
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     string word = "turpentine and turtles";
  9.     vector <char> vowels = { 'a','e','i','o','u' };
  10.     vector <char> result;
  11.     for (int i = 0; i < word.size();i++)
  12.     {
  13.         for (int j = 0; j < vowels.size();j++)
  14.         {
  15.             if (word[i] == vowels[j])
  16.             {
  17.                 result.push_back(word[i]);
  18.                 if (word[i] == 'e' || word[i] == 'u') {
  19.  
  20.                     result.push_back(word[i]);
  21.                 }
  22.             }
  23.            
  24.         }
  25.        
  26.     }
  27.     for (int k = 0; k < result.size();k++)
  28.         {
  29.             cout << result[k];
  30.         }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement