예제 #1
0
        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);
        }
예제 #2
0
        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();
        }
예제 #3
0
 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}] : ")
             };
         }
     }
 }
예제 #4
0
        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);
        }