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

Friday, June 12, 2015

Enter the number: 5

*                      *
* *               *  *        
* * *          * * *
* * * *    * * * *
* * * * * * * * * 
* * * *    * * * *
* * *          * * *
* *                * *
*                      *

 class Program

{

    static void Main(string[] args)

    {

        int n, A, B = 0;

        Console.WriteLine("enter no of rows u want ");

        n = int.Parse(Console.ReadLine());

        A = n * 2 - 1;

        B = n;

        for (int row = 1; row <= A; row++)

        {

            for (int coll = 1; coll <= A; coll++)

            {

                if (row <= n)

                {

                    if (coll <= row)

                    {

                        Console.Write("*");

                    }

                    else

                    {

                        if (coll < (n * 2 - row))

                        {

                            Console.Write(" ");

                        }

                        else

                        {

                            Console.Write("*");

                        }

                    }

                }

                else

                {

                    if (coll <= B + 3)

                    {

                        Console.Write("*");

                        B--;

                    }

                    else

                    {

                        if (row - coll > 0)

                        {

                            Console.Write(" ");

                        }

                        else

                        {

                            Console.Write("*");

                        }

                    }


                }


            }

            Console.WriteLine();


        }

        Console.ReadLine();

    }

}

No comments: