Vous êtes sur la page 1sur 1

using System;

using System.Runtime.InteropServices;

namespace _6
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Введите размер матрицы:");
int n = Convert.ToInt32(Console.ReadLine());
int m = Convert.ToInt32(Console.ReadLine());
Console.WriteLine();
double[,] matrix = new double[n, m];
Random rand = new Random();
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
matrix[i, j] = rand.NextDouble() * 20;
Console.Write(String.Format("{0:0.00}", matrix[i, j]) + "\t");
}
Console.WriteLine();
}
double[] array = new double[n];
double[] array_col = new double[m];
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
array[i] += matrix[i, j];
array_col[j] += matrix[i, j];
}
}
double min = 1000,
max = -1000;
for (int i = 0; i < n; i++)
{
if (array[i] < min)
{
min = array[i];
}
}
for (int j = 0; j < m; j++)
{
if (array_col[j] > max)
{
max = array_col[j];
}
}
Console.WriteLine("\nМинимальная сумма среди сумм элементов строк: " +
String.Format("{0:0.00}", min));
Console.WriteLine("Максимальная сумма среди сумм элементов столбоцов: "
+ String.Format("{0:0.00}", max));
}
}
}

Vous aimerez peut-être aussi