Đề bài
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.
Ràng buộc
0 ≤ length of text ≤ 10,000 (ASCII characters)
Ví dụ
Ví dụ 1
Đầu vào:
text = "Hello World"
Kết quả mong đợi:
expected = 2
Đầu vào:
std::string text = "Hello World";
Kết quả mong đợi:
long long expected = 2;
Đầu vào:
string text = "Hello World";
Kết quả mong đợi:
long expected = 2;
Giải thích
H and W are uppercase: 2.
Ví dụ 2
Đầu vào:
text = "no caps here!"
Kết quả mong đợi:
expected = 0
Đầu vào:
std::string text = "no caps here!";
Kết quả mong đợi:
long long expected = 0;
Đầu vào:
string text = "no caps here!";
Kết quả mong đợi:
long expected = 0;
Giải thích
There are no uppercase letters: 0.
Tham khảo
Thử thách này đã được điều chỉnh cho CodeUtility. Hãy làm theo đề bài và các ràng buộc ở trên.