Problema
Ver traduçãoCount how many characters in text are vowels: a, e, i, o, u in either uppercase or lowercase.
Implement count_vowels(text).
Input
text: The text to inspect (ASCII characters).
Output
Return the number of vowels.
Restrições
0 ≤ length ≤ 10,000
Exemplos
Exemplo 1
Entrada:
text = "Hello World"
Saída esperada:
expected = 3
Entrada:
std::string text = "Hello World";
Saída esperada:
long long expected = 3;
Entrada:
string text = "Hello World";
Saída esperada:
long expected = 3;
Explicação
e, o and o are vowels: 3.
Exemplo 2
Entrada:
text = "AEIOU and y"
Saída esperada:
expected = 6
Entrada:
std::string text = "AEIOU and y";
Saída esperada:
long long expected = 6;
Entrada:
string text = "AEIOU and y";
Saída esperada:
long expected = 6;
Explicação
A, E, I, O, U, a are vowels; y is not counted: 6.
Referências
Este desafio foi adaptado para o CodeUtility. Siga o enunciado e as restrições acima.