Đề bài
Xem bản dịchCount 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.
Ràng buộc
0 ≤ length ≤ 10,000
Ví dụ
Ví dụ 1
Đầu vào:
text = "Hello World"
Kết quả mong đợi:
expected = 3
Đầu vào:
std::string text = "Hello World";
Kết quả mong đợi:
long long expected = 3;
Đầu vào:
string text = "Hello World";
Kết quả mong đợi:
long expected = 3;
Giải thích
e, o and o are vowels: 3.
Ví dụ 2
Đầu vào:
text = "AEIOU and y"
Kết quả mong đợi:
expected = 6
Đầu vào:
std::string text = "AEIOU and y";
Kết quả mong đợi:
long long expected = 6;
Đầu vào:
string text = "AEIOU and y";
Kết quả mong đợi:
long expected = 6;
Giải thích
A, E, I, O, U, a are vowels; y is not counted: 6.
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.