โจทย์
ดูฉบับแปลCount 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.
เงื่อนไข
0 ≤ length ≤ 10,000
ตัวอย่าง
ตัวอย่างที่ 1
อินพุต:
text = "Hello World"
ผลลัพธ์ที่คาดหวัง:
expected = 3
อินพุต:
std::string text = "Hello World";
ผลลัพธ์ที่คาดหวัง:
long long expected = 3;
อินพุต:
string text = "Hello World";
ผลลัพธ์ที่คาดหวัง:
long expected = 3;
คำอธิบาย
e, o and o are vowels: 3.
ตัวอย่างที่ 2
อินพุต:
text = "AEIOU and y"
ผลลัพธ์ที่คาดหวัง:
expected = 6
อินพุต:
std::string text = "AEIOU and y";
ผลลัพธ์ที่คาดหวัง:
long long expected = 6;
อินพุต:
string text = "AEIOU and y";
ผลลัพธ์ที่คาดหวัง:
long expected = 6;
คำอธิบาย
A, E, I, O, U, a are vowels; y is not counted: 6.
แหล่งอ้างอิง
โจทย์นี้ปรับให้เหมาะกับ CodeUtility กรุณาทำตามคำชี้แจงและข้อจำกัดด้านบน