โจทย์
Compute the average (arithmetic mean) of three integers. The result can have a fractional part.
Implement average_of_three(a, b, c).
Input
a: The first number. b: The second number. c: The third number.
Output
Return (a + b + c) / 3 as a decimal number.
เงื่อนไข
-1,000,000 ≤ a, b, c ≤ 1,000,000
ตัวอย่าง
ตัวอย่างที่ 1
อินพุต:
a = 2
b = 4
c = 9
ผลลัพธ์ที่คาดหวัง:
expected = 5.0
อินพุต:
long long a = 2;
long long b = 4;
long long c = 9;
ผลลัพธ์ที่คาดหวัง:
double expected = 5.0;
อินพุต:
long a = 2;
long b = 4;
long c = 9;
ผลลัพธ์ที่คาดหวัง:
double expected = 5.0;
คำอธิบาย
2 + 4 + 9 = 15 and 15 / 3 = 5.
ตัวอย่างที่ 2
อินพุต:
a = 1
b = 2
c = 2
ผลลัพธ์ที่คาดหวัง:
expected = 1.666667
อินพุต:
long long a = 1;
long long b = 2;
long long c = 2;
ผลลัพธ์ที่คาดหวัง:
double expected = 1.666667;
อินพุต:
long a = 1;
long b = 2;
long c = 2;
ผลลัพธ์ที่คาดหวัง:
double expected = 1.666667;
คำอธิบาย
1 + 2 + 2 = 5 and 5 / 3 ≈ 1.666667. Divide as decimals, not whole numbers.
แหล่งอ้างอิง
โจทย์นี้ปรับให้เหมาะกับ CodeUtility กรุณาทำตามคำชี้แจงและข้อจำกัดด้านบน