public static Element[,] MatrixInitialize() { int rowsNumber = InputAndOutput.GetNumberFromUser("Enter number of rows : "); int columnsNumber = InputAndOutput.GetNumberFromUser("Enter number of columns : "); Element[,] matrix = new Element[rowsNumber, columnsNumber]; _matrixRateInitialize(matrix); return(matrix); }
static void Main(string[] args) { var mainMatrix = MatrixInitializer.MatrixInitialize(); (int[] demands, int[] stocks) = DemandsAndStocksInitializer.DemandsAndStocksInitialize(mainMatrix); TrafficCalculator.MatrixTrafficCheck(mainMatrix, demands, stocks); InputAndOutput.ResultOutput(mainMatrix); Console.ReadKey(); }
private static void _matrixRateInitialize(Element[,] matrix) { for (var rowNumber = 0; rowNumber < matrix.GetLength(0); rowNumber++) { for (var columnNumber = 0; columnNumber < matrix.GetLength(1); columnNumber++) { matrix[rowNumber, columnNumber] = new Element { Value = InputAndOutput. GetNumberFromUser($"Enter rate of [{rowNumber}, {columnNumber}] : ") }; } } }
public static (int[], int[]) DemandsAndStocksInitialize(Element[,] matrix) { int[] demands = new int[matrix.GetLength(1)]; for (var rowNumber = 0; rowNumber < matrix.GetLength(1); rowNumber++) { demands[rowNumber] = InputAndOutput.GetNumberFromUser($"Enter demand #{rowNumber} : "); } int[] stocks = new int[matrix.GetLength(0)]; for (var columnNumber = 0; columnNumber < matrix.GetLength(0); columnNumber++) { stocks[columnNumber] = InputAndOutput.GetNumberFromUser($"Enter stock #{columnNumber} : "); } return(demands, stocks); }