Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- int rowForSumm = 2;
- int collumForMultiply = 1;
- Console.WriteLine($"Программа генерирует случайный массив и выводит сумму элементов строки {rowForSumm} и произведение элементов столбца {collumForMultiply}");
- int rowsCount = 3;
- int columnsCount = 3;
- int[,] array = new int[rowsCount, columnsCount];
- int minValue = 0;
- int maxValue = 9;
- Random random = new Random();
- int sumResult = 0;
- int mltiplyResult = 1;
- Console.WriteLine("Сгенерированный массив:");
- for (int i = 0; i < array.GetLength(0); i++)
- {
- for (int j = 0; j < array.GetLength(1); j++)
- {
- array[i, j] = random.Next(minValue, maxValue + 1);
- Console.Write(array[i, j] + " ");
- }
- Console.WriteLine();
- }
- for (int i = 0; i < array.GetLength(0); i++)
- mltiplyResult *= array[i, collumForMultiply - 1];
- for (int j = 0; j < array.GetLength(1); j++)
- sumResult += array[rowForSumm - 1, j];
- Console.WriteLine($"Сумма элементов строки {rowForSumm}: {sumResult}\nПроизведение элементов столбца {collumForMultiply}: {mltiplyResult}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment