Ввести одномерный массив А из 13 элементов . Определить в нём сумму модулей отрицательных элементов.
Ответы на вопрос
Ответ:
PascalABC.NET
begin
var A := ReadArrInteger('введите массив с клавиатуры: ', 13);
A.Where(x-> x < 0).Select(x -> abs(x)).Sum.Println;
end.
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
int n = 13;
int[] array = new int[n];
int result = 0;
for (int i = 0; i < n; i++)
{
array[i] = int.Parse(Console.ReadLine());
if (array[i] < 0)
result += Math.Abs(array[i]);
}
Console.WriteLine("Cумма модулей отрицательных элементов равна {0}", result);
Console.ReadKey();
}
}
}