Text: |
ФІО = Козько
Запитання:Реалызувати метод, який пыдраховуе кылькысть парних елементыв заданого дыйсного масиву
====================================
ANSWER ====================================
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
const int max=4;
double [] mas = new double [max];
for (int i = 0; i < max; i++)
{
mas[i]=Convert.ToDouble( Console.ReadLine());
}
double sum = 0;
for (int i = 0; i < max; i++)
{
if (mas[i] % 2 == 0) { sum ++; }
}
Console.WriteLine("Sum = {0}",sum);
Console.ReadKey();
}
}
}
END of ANSWER ====================================
ANSWER ====================================
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication18
{
class Program
{
const int max = 4;
static double[] mas = new double[max];
static void fillmas()
{
for (int i = 0; i < max; i++)
{
mas[i] = Convert.ToDouble(Console.ReadLine());
}
}
static double rez()
{
double sum = 0;
for (int i = 0; i < max; i++)
{
if (mas[i] % 2 == 0) { sum++; }
}
return sum;
}
static void Main(string[] args)
{
fillmas();
Console.WriteLine("Rez = {0}", rez());
Console.ReadLine();
}
}
}
END of ANSWER ====================================
|