Console.Write("size = ");
int size = int.Parse(Console.ReadLine());
int[] arr = new int[size];
for(int i = 0; i < arr.Length; i++)
{
Console.Write($"arr[{i}] = ");
arr[i] = int.Parse(Console.ReadLine());
}
int iMax = 0;
for(int i = 1; i < arr.Length; i++)
if(arr[iMax] < arr[i]) iMax = i;
Console.WriteLine($"Индекс максимального элемента = {iMax}, значение = {arr[iMax]}.");
Console.WriteLine("Полученный массив:")
if(iMax != 0)
int temp = arr[0];
arr[0] = arr[iMax];
arr[iMax] = temp;
Console.Write($"{arr[i]} ");
Console.ReadKey();
using System;
using System.Collections;
namespace Application
class MainClass
public static void Main (string[] args)
int M = 4, N = 4;
int[,] A = new int[M, N];
Random gen = new Random ();
ArrayList listMinElements = new ArrayList ();
for (int i = 0; i < M; i++)
int min = int.MaxValue;
for (int j = 0; j < N; j++)
A [i, j] = gen.Next (1, 20);
Console.Write ("{0,4}", A [i, j]);
if (A [i, j] < min)
min = A [i, j];
listMinElements.Add (min);
Console.WriteLine ();
for (int i = 0; i < listMinElements.Count; i++)
Console.WriteLine ("Min element in row {0} equal {1}", i, listMinElements [i]);
int minElement = int.MaxValue;
int maxElement = int.MinValue;
foreach (int item in A)
if (item > maxElement) {
maxElement = item;
if (item < minElement) {
minElement = item;
int sum = 0;
int k = M * N;
if (item != minElement && item != maxElement) {
sum += item;
} else {
--k;
double middle_value = (double)sum / k;
Console.WriteLine ("\nMiddle value: " + middle_value);
Console.Write("size = ");
int size = int.Parse(Console.ReadLine());
int[] arr = new int[size];
for(int i = 0; i < arr.Length; i++)
{
Console.Write($"arr[{i}] = ");
arr[i] = int.Parse(Console.ReadLine());
}
int iMax = 0;
for(int i = 1; i < arr.Length; i++)
if(arr[iMax] < arr[i]) iMax = i;
Console.WriteLine($"Индекс максимального элемента = {iMax}, значение = {arr[iMax]}.");
Console.WriteLine("Полученный массив:")
if(iMax != 0)
{
int temp = arr[0];
arr[0] = arr[iMax];
arr[iMax] = temp;
}
for(int i = 0; i < arr.Length; i++)
Console.Write($"{arr[i]} ");
Console.ReadKey();
using System;
using System.Collections;
namespace Application
{
class MainClass
{
public static void Main (string[] args)
{
int M = 4, N = 4;
int[,] A = new int[M, N];
Random gen = new Random ();
ArrayList listMinElements = new ArrayList ();
for (int i = 0; i < M; i++)
{
int min = int.MaxValue;
for (int j = 0; j < N; j++)
{
A [i, j] = gen.Next (1, 20);
Console.Write ("{0,4}", A [i, j]);
if (A [i, j] < min)
min = A [i, j];
}
listMinElements.Add (min);
Console.WriteLine ();
}
Console.WriteLine ();
for (int i = 0; i < listMinElements.Count; i++)
{
Console.WriteLine ("Min element in row {0} equal {1}", i, listMinElements [i]);
}
int minElement = int.MaxValue;
int maxElement = int.MinValue;
foreach (int item in A)
{
if (item > maxElement) {
maxElement = item;
}
if (item < minElement) {
minElement = item;
}
}
int sum = 0;
int k = M * N;
foreach (int item in A)
{
if (item != minElement && item != maxElement) {
sum += item;
} else {
--k;
}
}
double middle_value = (double)sum / k;
Console.WriteLine ("\nMiddle value: " + middle_value);
}
}
}