ง่าย 0 ข้อที่แก้แล้ว อัตราผ่าน 0%

Count Uppercase Letters

Count the capital letters in a text.

โจทย์

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.

เงื่อนไข

0 ≤ length of text ≤ 10,000 (ASCII characters)

ตัวอย่าง

ตัวอย่างที่ 1
อินพุต:
text = "Hello World"

ผลลัพธ์ที่คาดหวัง:
expected = 2
อินพุต:
std::string text = "Hello World";

ผลลัพธ์ที่คาดหวัง:
long long expected = 2;
อินพุต:
string text = "Hello World";

ผลลัพธ์ที่คาดหวัง:
long expected = 2;

คำอธิบาย

H and W are uppercase: 2.

ตัวอย่างที่ 2
อินพุต:
text = "no caps here!"

ผลลัพธ์ที่คาดหวัง:
expected = 0
อินพุต:
std::string text = "no caps here!";

ผลลัพธ์ที่คาดหวัง:
long long expected = 0;
อินพุต:
string text = "no caps here!";

ผลลัพธ์ที่คาดหวัง:
long expected = 0;

คำอธิบาย

There are no uppercase letters: 0.

แหล่งอ้างอิง

โจทย์นี้ปรับให้เหมาะกับ CodeUtility กรุณาทำตามคำชี้แจงและข้อจำกัดด้านบน

เรียนรู้จากคนอื่น

แนวทางจากชุมชน

ยังไม่มีวิธีทำที่เผยแพร่ ลองแก้โจทย์นี้เพื่อแชร์วิธีแรก