โจทย์
Count how many numbers in the list are greater than zero. Zero is neither positive nor negative.
Implement count_positives(numbers).
Input
numbers: The list of integers.
Output
Return the count.
เงื่อนไข
0 ≤ length ≤ 100,000; each value fits in a 64-bit integer
ตัวอย่าง
ตัวอย่างที่ 1
อินพุต:
numbers = [3, -1, 0, 7, 2]
ผลลัพธ์ที่คาดหวัง:
expected = 3
อินพุต:
std::vector<long long> numbers = {3, -1, 0, 7, 2};
ผลลัพธ์ที่คาดหวัง:
long long expected = 3;
อินพุต:
long[] numbers = new long[] {3, -1, 0, 7, 2};
ผลลัพธ์ที่คาดหวัง:
long expected = 3;
คำอธิบาย
3, 7 and 2 are positive: 3.
ตัวอย่างที่ 2
อินพุต:
numbers = [0, 0, -5]
ผลลัพธ์ที่คาดหวัง:
expected = 0
อินพุต:
std::vector<long long> numbers = {0, 0, -5};
ผลลัพธ์ที่คาดหวัง:
long long expected = 0;
อินพุต:
long[] numbers = new long[] {0, 0, -5};
ผลลัพธ์ที่คาดหวัง:
long expected = 0;
คำอธิบาย
No value is above zero: 0.
แหล่งอ้างอิง
โจทย์นี้ปรับให้เหมาะกับ CodeUtility กรุณาทำตามคำชี้แจงและข้อจำกัดด้านบน