-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreversing_the_vowel.cpp
44 lines (36 loc) · 1.11 KB
/
reversing_the_vowel.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
Link:-https://practice.geeksforgeeks.org/problems/reversing-the-vowels5304/1
problem:- Given a string consisting of lowercase english alphabets, reverse only the vowels present in it and print the resulting string.
Input:
S = "geeksforgeeks"
Output: geeksforgeeks
Explanation: The vowels are: e, e, o, e, e
Reverse of these is also e, e, o, e, e.
Input:
S = "practice"
Output: prectica
Explanation: The vowels are a, i, e
Reverse of these is e, i, a.
*/
string modify (string s)
{
//code here.
string vowel="";
for(int i=0;i<s.length();i++)
{
if(s[i]=='a' || s[i]=='e' || s[i]=='i' || s[i]=='o' || s[i]=='u')
{
vowel+=s[i];
}
}
int n=vowel.length();
for(int i=0;i<s.length();i++)
{
if(s[i]=='a' || s[i]=='e' || s[i]=='i' || s[i]=='o' || s[i]=='u')
{
s[i]=vowel[n-1];
n--;
}
}
return s;
}