--- C# 7.3 ---
using System; 
using System.Collections; 
using System.Collections.Generic; 
using System.Linq; 
namespace CSLear 
{ 
    partial class Program 
    { 
        static void Main(string[] args) 
        { 
            int n = int.Parse(Console.ReadLine()); 
            int[,] Matr = MatrixRandomize(n, n, -99, 99); 
            MatrixPrint(Matr); 
            Console.WriteLine(Matr.GetMatrRow(IntMatrRowOfMaxIndex(Matr)).Aggregate(1f, (x, y) => x * y)); 
            Console.ReadKey(); 
        } 
        private static int IntMatrRowOfMaxIndex(in int[,] Matr) 
        { 
            int max = int.MinValue; 
            int RowOfMax = 0; 
            for (int i = 0; i < Matr.GetLength(0); i++) 
            { 
                for (int j = 0; j < Matr.GetLength(1); j++) 
                { 
                    if (Matr[i, j] > max) 
                    { 
                        max = Matr[i, j]; 
                        RowOfMax = i; 
                    } 
                } 
            } 
            return RowOfMax; 
        } 
        public static int[,] MatrixRandomize(int ArrRows, int ArrCols, int minValue, int maxValue) 
        { 
            Random r = new Random(); 
            int[,] Arr = new int[ArrRows, ArrCols]; 
            for (int i = 0; i < ArrRows; i++) 
            { 
                for (int j = 0; j < ArrCols; j++) 
                { 
                    Arr[i, j] = r.Next(minValue, maxValue); 
                } 
            } 
            return Arr; 
        }
        public static void MatrixPrint<T>(T[,] Matr) 
        { 
            StringBuilder sb = new StringBuilder(); 
            for (int i = 0; i < Matr.GetLength(0); i++) 
            { 
                for (int j = 0; j < Matr.GetLength(1); j++) 
                { 
                    sb.Append($"{Matr[i, j]} "); 
                } 
                sb.Append("\n"); 
            } 
            Console.WriteLine(sb.ToString()); 
        }
    } 
    public static class Extensions 
    {
        public static T[] GetMatrRow<T>(this T[,] Matr, int Row) 
        { 
            if (!typeof(T).IsPrimitive) 
                throw new InvalidOperationException("Supports only primitive types"); 
            if (Matr == null) 
                throw new NullReferenceException("Null Matrix"); 
            T[] Res = new T[Matr.GetLength(1)]; 
            int RowLength = Matr.GetLength(0); 
            for (int i = 0; i < RowLength; i++) 
            { 
                Res[i] = Matr[Row, i]; 
            } 
            return Res; 
        } 
    }
} 
Программа выдаёт ответ в виде числа типа Single, т.к результат перемножения строки матрицы может сильно выходить даже за предел Int64
Популярные вопросы