We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Sunday, June 14, 2015

Enter the row number:5

5 5 5 5 5 5 5 5 5
5 4 4 4 4 4 4 4 5
5 4 3 3 3 3 3 4 5
5 4 3 2 2 2 3 4 5
5 4 3 2 1 2 3 4 5
5 4 3 2 2 2 3 4 5
5 4 3 3 3 3 3 4 5
5 4 4 4 4 4 4 4 5
5 5 5 5 5 5 5 5 5

   class Program
    {

        static void Main(string[] args)
        {

            Console.WriteLine("Enter the row number");
            int n = int.Parse(Console.ReadLine());
            for (int row = 1; row <= 2 * n - 1; row++)
            {

                for (int coll = 1; coll <= 2 * n - 1; coll++)
                {

                    if (row == 1 || coll == 1 || coll == 2 * n - 1 || row == 2 * n - 1)
                    {

                        Console.Write(n);

                    }
                    else if (row == 2 || coll == 2 || coll == 2 * n - 2 || row == 2 * n - 2)
                    {

                        Console.Write(n - 1);
                    }
                    else if (row == 3 || coll == 3 || coll == 2 * n - 3 || row == 2 * n - 3)
                    {
                        Console.Write(n - 2);
                    }
                    else if (row == 4 || coll == 4 || coll == 2 * n - 4 || row == 2 * n - 4)
                    {
                        Console.Write(n - 3);
                    }
                    else
                        Console.Write(n - 4);
                }
                Console.WriteLine();

            }
            Console.ReadLine();
        }


    }

No comments: