예제 #1
0
        public string GetTaskResult(TaskExtractor extractor)
        {
            string taskResult;

            if (extractor.GetNumber(out int number, new string[] { "Input number", "Input number must be greater than zero:" }) && number > 0)
            {
                taskResult = $"Fibonachi sequence = {OutputService.ConvertIEnumerableToString(FindFibonachiSequence(number))}";
            }
예제 #2
0
        public string GetTaskResult(TaskExtractor extractor)
        {
            string taskResult;

            if (extractor.GetNumber(out var arrSize, "Input array size:"))
            {
                var arr = extractor.GetRandomDoubleEnumerable(arrSize).ToArray();
                taskResult = string.Concat
                             (
                    $"{OutputService.ConvertIEnumerableToString(arr)} \nThe sum of the negative elements =",
                    $"{FindSumNegativeElements(arr)}\n",
                    $"The product of the elements of the vector located between the maximum and minimum elements. =",
                    $"{FindMultiplyOfElementsBetweenMaxAndMin(arr)}"
                             );
            }
            else
            {
                taskResult = "Input error: Invalid array size!";
            }
            return(taskResult);
        }
예제 #3
0
        public string GetTaskResult(TaskExtractor extractor)
        {
            string taskResult;

            if (extractor.GetNumber(out var arrSize, "Input array size:"))
            {
                var arr = extractor.GetRandomDoubleEnumerable(arrSize).ToArray();

                OutputService.ConvertIEnumerableToString(arr);

                taskResult = string.Concat(
                    $"{OutputService.ConvertIEnumerableToString(arr)} \nThe sum of the negative elements =",
                    $"Max number in the vector = { arr.Max() }\n" +
                    $"Sum elements before last positive = { Math.Round(SumElementsBeforeLastPositive(arr), 2) }");
            }
            else
            {
                taskResult = "Input error: Invalid array size!";
            }
            return(taskResult);
        }