I am starting learning how to code now and I saw this website
which is Ubbi Dubbi translator and I am making my own now to however, I am stuck on the crucial part where I need to add ub after vowel sounds
here is my code ( just some functions that I tried)
bool contains_only_letters(string str)
{
for (int i = 0; i < str.length() ; i++)
if ( (str.at(i) <'a' || str.at(i) >'z') && (str.at(i) <'A' || str.at(i) >'Z'))
return false;
return true;
}
bool is_vowel(char ch)
{
return (ch =='A' || ch =='E' || ch =='I'|| ch =='0'|| ch =='U'
|| ch =='a' || ch =='e' || ch =='i'|| ch =='o'|| ch =='u');
}
string translate_to_Ubbi_Dubb(string str)
{
string translated;
if (contains_only_letters(str))
{
if (is_vowel(str.at(0)))
translated = str + "ub"; *// here is where I don't know how to add ub*
}
else
translated = str;
return translated;
please help I wanna get a hand of it. By the way, this is c++ Thanks ^^
Aucun commentaire:
Enregistrer un commentaire