Пример #1
0
        public static void Main()
        {
            int column;

            Console.Write("Enter the rows: ");
            int row = FindMininArray.enterSize();

            Console.Write("Enter the colums: ");
            int col = FindMininArray.enterSize();

            float[,] array = generateArray2waybykeyboard(row, col);
            FindLargestElementInArray.printArray2Way(array);
            do
            {
                Console.WriteLine("Enter the column to sum: ");
                column = int.Parse(Console.ReadLine());
                if (column < 0 || column >= col)
                {
                    Console.WriteLine($"The colomn of size is from 0 to {col - 1}: ");
                }
            }while (column < 0 || column >= col);
            float sum = sumInGivenColumn(array, column);

            Console.WriteLine($"Sum in given {column} is: {sum}");
        }
Пример #2
0
        public static void Main()
        {
            int   size = FindMininArray.enterSize();
            float sum = 0, sum1 = 0;

            float[,] array = FindLargestElementInArray.GenerateArray(size, size);
            FindLargestElementInArray.printArray2Way(array);
            for (byte i = 0, j = 0; i < array.GetLength(0); i++, j++)
            {
                sum += array[i, j];
            }
            for (int i = 0, j = array.GetLength(0) - 1; i < array.GetLength(0); i++, j--)
            {
                sum1 += array[i, j];
            }
            Console.WriteLine($"Sum the numbers on the main diagonal: {sum}");
            Console.WriteLine($"sum the numbers on the diagonal sub: {sum1}");
        }