Problème
Count how many characters in text are uppercase English letters A–Z.
Implement count_uppercase(text).
Input
text: The text to inspect.
Output
Return the number of uppercase letters.
Contraintes
0 ≤ length of text ≤ 10,000 (ASCII characters)
Exemples
Exemple 1
Entrée :
text = "Hello World"
Sortie attendue :
expected = 2
Entrée :
std::string text = "Hello World";
Sortie attendue :
long long expected = 2;
Entrée :
string text = "Hello World";
Sortie attendue :
long expected = 2;
Explication
H and W are uppercase: 2.
Exemple 2
Entrée :
text = "no caps here!"
Sortie attendue :
expected = 0
Entrée :
std::string text = "no caps here!";
Sortie attendue :
long long expected = 0;
Entrée :
string text = "no caps here!";
Sortie attendue :
long expected = 0;
Explication
There are no uppercase letters: 0.
Références
Ce défi a été adapté pour CodeUtility. Suivez l'énoncé et les contraintes ci-dessus.