コード例 #1
0
        static void Main(string[] args)
        {
            int m;

            int        format     = InputParametrs();
            MatrixSize matrixSize = InputMatrixSize();

            int[,] myMatrix;
            myMatrix = new int[matrixSize.Rows, matrixSize.Columns];

            FillMatrix(matrixSize, myMatrix);

            BuildTopOfMatrix(format, matrixSize);

            BuildVerticalLines(matrixSize, format, myMatrix);

            BuildLastLine(format, myMatrix, matrixSize);

            BuildUnderLine(format, matrixSize);

            Console.WriteLine();
            Console.ReadKey();


            var newString = TakeStringNtimes("═", format);

            // 5, "═" --> ══════


            Console.WriteLine(newString);
        }
コード例 #2
0
        private static void BuildVerticalLines(MatrixSize matrixSize, int format, int[,] matrix)
        {
            int m;

            for (m = 0; m < (matrixSize.Columns - 1); m++)
            {
                Console.Write("║");
                for (int i = 0; i < matrixSize.Rows; i++)
                {
                    for (int j = 0; j < matrixSize.Columns; j++)
                    {
                        matrix[i, j] = i * j;
                    }
                    Console.Write($"{matrix[i, m].ToString().PadLeft(format)}" + "║");
                }

                //
                Console.WriteLine();
                Console.Write("╠" + TakeStringNtimes("═", (format / 2 + 1)));
                for (int n = 0; n < (matrixSize.Rows - 1); n++)
                {
                    Console.Write(TakeStringNtimes("═", (format / 2)) + "╬" + TakeStringNtimes("═", (format / 2 + 1)));
                }
                Console.Write(TakeStringNtimes("═", (format / 2)) + "╣");
                Console.WriteLine();
            }
        }
コード例 #3
0
 private static void BuildTopOfMatrix(int format, MatrixSize matrixSize)
 {
     Console.Write("╔" + TakeStringNtimes("═", format));
     for (int n = 0; n < (matrixSize.Rows - 1); n++)
     {
         Console.Write("╦" + TakeStringNtimes("═", format));
     }
     Console.Write("╗");
     Console.WriteLine();
 }
コード例 #4
0
 private static void FillMatrix(MatrixSize size, int[,] matrix)
 {
     for (int i = 0; i < size.Rows; i++)
     {
         for (int j = 0; j < size.Columns; j++)
         {
             matrix[i, j] = i * j;
         }
     }
 }
コード例 #5
0
 private static void BuildUnderLine(int format, MatrixSize matrixSize)
 {
     Console.Write("╚" + TakeStringNtimes("═", format));
     for (int n = 0; n < (matrixSize.Rows - 1); n++)
     {
         Console.Write("╩" + TakeStringNtimes("═", format));
     }
     Console.Write("╝");
     Console.WriteLine();
 }
コード例 #6
0
        private static MatrixSize InputMatrixSize()
        {
            MatrixSize size = new MatrixSize();

            Console.WriteLine("Enter columns: ");
            size.Columns = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Enter rows: ");
            size.Rows = Convert.ToInt32(Console.ReadLine());

            return(size);
        }
コード例 #7
0
 private static void BuildLastLine(int format, int[,] matrix, MatrixSize matrixSize)
 {
     Console.Write("║");
     for (int i = 0; i < matrixSize.Rows; i++)
     {
         for (int j = 0; j < matrixSize.Columns; j++)
         {
             matrix[i, j] = i * j;
         }
         Console.Write($"{matrix[i, (matrixSize.Columns - 1)].ToString().PadLeft(format)}" + "║");
     }
     Console.WriteLine();
 }