Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace homeWorkWorkingWithSpecificRowsOrColumns
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- Random random = new Random();
- int countRows = 3;
- int countCols = 3;
- int[,] matrix = new int[countRows, countCols];
- int minValue = 1;
- int maxValue = 100;
- int sumRow = 0;
- int prodColumn = 1;
- int numberRow = 2;
- int numberColumn = 1;
- for (int i = 0; i < countRows; i++)
- {
- for (int j = 0; j < countCols; j++)
- {
- matrix[i, j] = random.Next(minValue, maxValue + 1);
- }
- }
- Console.WriteLine("Исходная матрица:");
- for (int i = 0; i < countRows; i++)
- {
- for (int j = 0; j < countCols; j++)
- {
- Console.Write($"{matrix[i, j]} ");
- }
- Console.WriteLine();
- }
- for (int j = 0; j < countCols; j++)
- {
- sumRow += matrix[numberRow - 1, j];
- }
- for (int i = 0; i < countRows; i++)
- {
- prodColumn *= matrix[i, numberColumn - 1];
- }
- Console.WriteLine($"Сумма второй строки: {sumRow}");
- Console.WriteLine($"Произведение первого столбца: {prodColumn}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement