Text: |
ԲΠ= Êîåâ Ìèõàèë
Çàïèòàííÿ:Ðåàë³çóâàòè ìåòîä, ÿêèé ï³äðàõîâóº ê³ëüê³ñòü â³äºìíèõ åëåìåíò³â çàäàíîãî ä³éñíîãî ìàñèâó.
====================================
ANSWER ====================================
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
const int max = 5;
static double[] mas = new double[max];
static void zapolnit_masiv()
{
Console.WriteLine("Vvedite elementi masiva :");
for (int i = 0; i < max; i++)
{
Console.Write("[{0}] = ", i);
mas[i] = Convert.ToDouble(Console.ReadLine());
}
}
static double rezult()
{
double sum = 0;
for (int i = 0; i < max; i++)
{
if (mas[i] < 0) { sum++; }
}
return sum;
}
static void Main(string[] args)
{
zapolnit_masiv();
Console.WriteLine("SUM = {0}", rezult());
Console.ReadKey();
}
}
}
END of ANSWER ====================================
|