static void Main(string[] args) { int numberOfRows = ReadInt($"number of rows is: "); int numberOfColumns = ReadInt($"number of columns is: "); int[,] matrix = CreateRandomMatrix(numberOfRows, numberOfColumns); int ariphmeticMean = AriphmeticMean(matrix, numberOfColumns, numberOfRows); Console.WriteLine($"ariph mean is:{ariphmeticMean}"); ElementAndItsCoordinatesAndDifference[] elementAndItsCoordinatesAndDifferences = new ElementAndItsCoordinatesAndDifference[0]; for (int i = 0; i < numberOfRows; i++) { for (int j = 0; j < numberOfColumns; j++) { ElementAndItsCoordinates elementAndItsCoordinates = new ElementAndItsCoordinates(matrix[j, i], i, j); int difference = Math.Abs(matrix[j, i] - ariphmeticMean); ElementAndItsCoordinatesAndDifference elementAndItsCoordinatesAndDifference = new ElementAndItsCoordinatesAndDifference(elementAndItsCoordinates, difference); elementAndItsCoordinatesAndDifferences = RewriteElementAndItsCoordinate(elementAndItsCoordinatesAndDifferences, elementAndItsCoordinatesAndDifference); } } elementAndItsCoordinatesAndDifferences = SortArray(elementAndItsCoordinatesAndDifferences); elementAndItsCoordinatesAndDifferences = FindMinimalDifferences(elementAndItsCoordinatesAndDifferences); for (int i = 0; i < elementAndItsCoordinatesAndDifferences.Length; i++) { Console.WriteLine($"coordinate of element is: i = {elementAndItsCoordinatesAndDifferences[i].ElementAndItsCoordinates.CoordinateI} " + $"and j = {elementAndItsCoordinatesAndDifferences[i].ElementAndItsCoordinates.CoordinateJ}; " + $"value {elementAndItsCoordinatesAndDifferences[i].ElementAndItsCoordinates.Element}"); } Console.ReadKey(); }
public ElementAndItsCoordinatesAndDifference(ElementAndItsCoordinates elementAndItsCoordinates, int difference) { ElementAndItsCoordinates = elementAndItsCoordinates; Difference = difference; }