問題
翻訳を表示Return the total of all numbers in the list. An empty list sums to 0.
Implement sum_array(numbers).
Input
numbers: The list of integers.
Output
Return the sum.
制約
0 ≤ length ≤ 100,000; the total fits in a 64-bit integer
例
例 1
入力:
numbers = [1, 2, 3, 4]
期待される出力:
expected = 10
入力:
std::vector<long long> numbers = {1, 2, 3, 4};
期待される出力:
long long expected = 10;
入力:
long[] numbers = new long[] {1, 2, 3, 4};
期待される出力:
long expected = 10;
解説
1 + 2 + 3 + 4 = 10.
例 2
入力:
numbers = []
期待される出力:
expected = 0
入力:
std::vector<long long> numbers = {};
期待される出力:
long long expected = 0;
入力:
long[] numbers = new long[] {};
期待される出力:
long expected = 0;
解説
Nothing to add: 0.
参考資料
この課題はCodeUtility用に調整されています。上記の説明と制約に従ってください。