Created
November 25, 2020 14:38
-
-
Save karabanovbs/d1714de8e13e805218e63018dded1b0c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 2.5 Функции | |
// Создайте и проинициализируйте массив чисел с произвольным размером. Напишите функцию, которая вычисляет среднее арифметическое число массива и возвращает double результат. Распечатайте результат в консоли. | |
void main() { | |
List<num> arrayList = [1, 2, 3, 4, 6]; | |
double average(List<num> arrayList) { | |
return arrayList.reduce((accumulator, current) => accumulator + current) / arrayList.length; | |
} | |
print(average(arrayList)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment