Kindly assist to make this code insert "ob" after every vowel in a string entered by the user in C++. The code is adding a double "ob" before only the first vowel. Thanks.
#include <iostream>
#include <string>
#include <algorithm>
int main()
{
std::string s;
std::cin >> s;
std::string o ="ob";
for (char& v: s)
{
if (v == 'a' || v=='e' || v == 'i' || v == 'o' || v == 'u')
s = s.insert(s.find(v),o);
}
std::cout << s << std::endl;
}
Aucun commentaire:
Enregistrer un commentaire