Untitled
unknown
csharp
3 years ago
848 B
8
Indexable
using System;
//Найти среднее арифметическое отрицательных элементов массива
namespace hw3_avg_neg_arr
{
internal class Program
{
static void Main(string[] args)
{
const int size = 6;
int[] arr = new int[size];
double s = 0, count = 0;
Console.WriteLine($"Введите {size} элементов массива");
for (int i = 0; i < size; i++)
arr[i] = Int32.Parse(Console.ReadLine());
{
if (arr[i] < 0)
{
s += arr[i];
count++;
}
}
Console.WriteLine("Среднее:" + Math.Round(s / count, 3));
}
}
}
Editor is loading...