Advertisement
Best_Project

Reverse vowels in a given string_geeks

Jun 20th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include<string>
  3. #include<string.h>
  4. #include<algorithm>
  5. #include<vector>
  6. using namespace std;
  7.  
  8.  
  9. bool check(char c)
  10. {
  11.     return (c == 'u'||c=='e'||c == 'o'||c=='a'||c=='i') ? true:false;
  12. }
  13. int main() {
  14.  
  15.     int t;cin>>t;cin.ignore();
  16.     while (t--)
  17.     {
  18.         string s;cin>>s;int k = 0;
  19.         string t ="";
  20.         for (int i = 0; s[i] != '\0'; i++)
  21.         {
  22.             if(check(s[i])) t+= s[i];
  23.         }
  24.         for (int i = 0,j = t.length()-1; s[i] != '\0'; i++)
  25.         {
  26.  
  27.             if (check(s[i])&&j >= 0)
  28.             {
  29.                 cout<<t[j--];
  30.  
  31.             }
  32.             else
  33.             {
  34.                 cout<<s[i];
  35.             }
  36.         }
  37.         cout<<endl;
  38.  
  39.     }
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement