/
merdan
/
controlWorks_tests
Обзор
Документация
Войти
/
merdan
/
controlWorks_tests
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
Methods/RunningSum.cs
33 строки
805 B
merdan
I wrote the tests
15 ноя 2025, 04:36
15 ноя 2025, 04:36
7047a79
Код
Авторство
О чём код?
namespace Methods; public class RunningSum { public static int[] Get(int [] firstArray) { if (firstArray == null) { throw new ArgumentNullException(nameof(firstArray), " The array cannot be null!"); } if (firstArray.Length == 0) { throw new ArgumentException(" The array cannot be empty!", nameof(firstArray)); } if (firstArray.Length < 2) { firstArray[0] = 0; return firstArray; } int [] resultArray = new int [firstArray.Length]; resultArray[1] = firstArray[0]; for (int i=2; i<firstArray.Length; i++) { resultArray[i] = firstArray[i-1]+resultArray[i-1]; } return resultArray; } }