![](/user_photo/2706_HbeT2.jpg)
22Вариант
namespace КПЯП_22_вариант
{
class massi {
int m = 1, n = 1;
public massi() { m = 1; n = 1; }
public massi(int M, int N) { m = M; n = N; }
public void proizv() {
int m, n, k = 1;
m = this.m;
n = this.n;
int[] b = new int[m];
int[,] a = new int[m, n];
Random r = new Random();
Console.WriteLine("Исходная матрица");
for (int i=0; i < n; i++) {
for (int j = 0; j < m; j++) {
a[i, j] = r.Next(0, 10);
k = k * a[i, j];
Console.Write("{0}\t",a[i, j]);
b[i] = k;
}
Console.WriteLine();
k = 1;
}
Console.WriteLine("Результат произведения");
for (int i = 0; i < m; i++)
{
Console.Write("{0}\t", b[i]);
}
}
}
class Program
{
static void Main(string[] args)
{
massi a = new massi(5,5);
a.proizv();
Console.ReadKey();
}
}
}
16Вариант
namespace _16
{
class Program
{
static void Main(string[] args)
{
Mass m = new Mass();
double[,] mas = new double[3, 5];
Console.WriteLine("Введите значения:");
for (int i = 0; i < 3; i++)
{
Console.WriteLine();
for (int j = 0; j < 5; j++)
{
mas[i, j] =Convert.ToDouble(Console.ReadLine());
}
}
Console.WriteLine("Массив:");
for (int i = 0; i < 3; i++)
{
Console.WriteLine();
for (int j = 0; j < 5; j++)
{
Console.Write("\t" + mas[i,j]);
}
}
Console.WriteLine();
Console.WriteLine("Сумма положительных элементов:");
Console.Write(m.Summa(mas));
Console.WriteLine();
Console.WriteLine("Количество отрицательных элементов:");
Console.Write(m.SummaOtric(mas));
Console.ReadLine();
}
}
class Mass
{
public double s = 0;
public int ss = 0;
public double Summa(double[,] m1)
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 5; j++ )
{
if (m1[i,j] > 0) s += m1[i, j];
}
}
return s;
}
public int SummaOtric(double[,] m1)
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 5; j++)
{
if (m1[i, j] < 0) ss += 1;
}
}
return ss;
}
}}