簡単 0件解決済み 正答率0%

Average of Three

Average three whole numbers.

問題

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用に調整されています。上記の説明と制約に従ってください。

他の人の解答から学ぶ

コミュニティの解答

まだ公開された解答がありません。この課題を解いて最初の解答を共有しましょう。