1
2 2
3 3
4 4
5 5
4 4
3 3
2 2
1
2 2
3 3
4 4
5 5
4 4
3 3
2 2
1
 class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter number of lines");
            int n = int.Parse(Console.ReadLine());
            for (int row = 1; row <= n; row++)
            {
                for (int space = n - row; space >= 1; space--)
                {
                    Console.Write(" ");
                }
                for (int col = 1; col <= (row * 2) - 1; col++)
                {
                    if (col == 1 || col == (row * 2) - 1)
                    {
                        Console.Write(row);
                    }
                    else
                    {
                        Console.Write(" ");
                    }
                }
                Console.WriteLine();
            }
            for (int row = n - 1; row >= 1; row--)
            {
                for (int space = 1; space <= n - row; space++)
                {
                    Console.Write(" ");
                }
                for (int col = row * 2 - 1; col >= 1; col--)
                {
                    if (col == (row * 2) - 1 || col == 1)
                    {
                        Console.Write(row);
                    }
                    else
                    {
                        Console.Write(" ");
                    }
                }
                Console.WriteLine();
            }
            Console.ReadLine();
        }
    }
 
 
No comments:
Post a Comment