Найти произведение непарных элементов-C#(Си шарп)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
class HelloWorld
{
    static void Main()
    {
        int result = 1;
        int[] array = new int[12];
        Random rand = new Random();
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = -5 + rand.Next(21);
        }
        for (int i = 0; i < array.Length; i++)
        {
            if (i % 2 == 0)
            {
                result = result * array[i];
 
            }
            Console.Write(array[i]+" ");
        }
        Console.Write("Результат непарных элементов: " + result);
    }
}

Leave a Comment