Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Summ_and_multiply
- {
- class Program
- {
- static void Main(string[] args)
- {
- int rows, columns;
- Random rand = new Random();
- int summ = 0, multiply = 1;
- Console.WriteLine("Добро пожаловать, введите размерность матрицы, после чего она заполнится случайными числами и произведет расчеты: ");
- Console.Write("Количество строк - ");
- rows = Convert.ToInt32(Console.ReadLine());
- Console.Write("Количество столбцов - ");
- columns = Convert.ToInt32(Console.ReadLine());
- int[,] array = new int[rows, columns];
- for (int i = 0; i < array.GetLength(0);i++)
- {
- for( int j = 0; j < array.GetLength(1); j++)
- {
- array[i, j] = rand.Next(0, 100);
- Console.Write(array[i, j] + " ");
- }
- Console.WriteLine();
- }
- for (int i = 0; i < array.GetLength(0); i++)
- {
- for (int j = 0; j < array.GetLength(1); j++)
- {
- if( i == 1)
- {
- summ += array[i, j];
- }
- if(j == 0)
- {
- multiply *= array[i, j];
- }
- }
- }
- Console.WriteLine("\nСумма второй строки равна - " + summ + "\nУмножение первого столбца равно - " + multiply);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement