--- C# 7.3 -- (.NET Framework 4.8)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CSLear
{
class Program
static void Main(string[] args)
Tuple<int, int> MatrixRange = new Tuple<int, int>(-10, 10);
int M = int.Parse(Console.ReadLine());
int N = int.Parse(Console.ReadLine());
int[,] Arr = new int[M,N];
ArrayRandomize(ref Arr, M, N, MatrixRange);
MatrixPrint(Arr, M, N);
int Negatives = Arr.Count(x => x < 0);
int Zero = Arr.Count(x => x == 0);
int Positives = Arr.Count(x => x > 0);
Console.WriteLine($"Positive Items: {Positives}\nNegative Items: {Negatives}\nZeroes: {Zero}");
Console.ReadKey();
}
public static void MatrixPrint<T>(T[,] Matrix, int MRows, int MCols)
StringBuilder sb = new StringBuilder();
for (int i = 0; i < MRows; i++)
for (int j = 0; j < MCols; j++)
sb.Append($"{Matrix[i, j]} ");
sb.Append("\n");
Console.WriteLine(sb.ToString());
public static void ArrayRandomize(ref int[,] Arr, int ArrRows, int ArrCols, Tuple<int, int> Range)
Random r = new Random();
for (int i = 0; i < ArrRows; i++)
for (int j = 0; j < ArrCols; j++)
Arr[i, j] = r.Next(Range.Item1, Range.Item2);
public static class Extensions
public static int Count<T>(this T[,] Matr, Func<T, bool> Predicate)
int counter = 0;
foreach (T Item in Matr)
if (Predicate(Item)) counter++;
return counter;
float a, b, c;
cout<<"Введите a: ";
cin>>a;
cout<<"Введите b: ";
cin>>b;
cout<<"Введите c: ";
cin>>c;
float D=b*b-4*a*c;
cout<<"ответ: ";
if(D>0)
cout<<"x1 = "<<(-b+sqrt(D))/2*a<<", x2 = "<<(-b-sqrt(D))/2*a;
else if(D==0)
cout<<"x = "<<-b/2*a;
else
cout<<"корней нет";
cout<<endl
//2
float a, b, c;
cout<<"Введите a: ";
cin>>a;
cout<<"Введите b: ";
cin>>b;
cout<<"Введите c: ";
cin>>c;
cout<<"Наибольшее число: ";
if(a>c)
if(a>b)
cout<<"a ("<<a<<")";
else
cout<<"b ("<<b<<")";
else if(c>b)
cout<<"c ("<<c<<")";
--- C# 7.3 -- (.NET Framework 4.8)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CSLear
{
class Program
{
static void Main(string[] args)
{
Tuple<int, int> MatrixRange = new Tuple<int, int>(-10, 10);
int M = int.Parse(Console.ReadLine());
int N = int.Parse(Console.ReadLine());
int[,] Arr = new int[M,N];
ArrayRandomize(ref Arr, M, N, MatrixRange);
MatrixPrint(Arr, M, N);
int Negatives = Arr.Count(x => x < 0);
int Zero = Arr.Count(x => x == 0);
int Positives = Arr.Count(x => x > 0);
Console.WriteLine($"Positive Items: {Positives}\nNegative Items: {Negatives}\nZeroes: {Zero}");
Console.ReadKey();
}
public static void MatrixPrint<T>(T[,] Matrix, int MRows, int MCols)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < MRows; i++)
{
for (int j = 0; j < MCols; j++)
{
sb.Append($"{Matrix[i, j]} ");
}
sb.Append("\n");
}
Console.WriteLine(sb.ToString());
}
public static void ArrayRandomize(ref int[,] Arr, int ArrRows, int ArrCols, Tuple<int, int> Range)
{
Random r = new Random();
for (int i = 0; i < ArrRows; i++)
{
for (int j = 0; j < ArrCols; j++)
{
Arr[i, j] = r.Next(Range.Item1, Range.Item2);
}
}
}
}
public static class Extensions
{
public static int Count<T>(this T[,] Matr, Func<T, bool> Predicate)
{
int counter = 0;
foreach (T Item in Matr)
{
if (Predicate(Item)) counter++;
}
return counter;
}
}
}