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

Wednesday, July 8, 2015

Enter the row number: 5

1 2 3 4 5

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

    class Program
    {
        static void Main(string[] args)
        {
            int count;
            Console.WriteLine("Enter the input row number");
            int num = int.Parse(Console.ReadLine());

            for (int row = 1; row <= num; row++)
            {
                count = row;
                for (int coll = 1; coll <= num; coll++)
                {
                    if (row == 1)
                    {
                        Console.Write(coll);
                    }
                    else
                    {
                        if (count == num + 1)
                        {
                            count = 1;
                            Console.Write(count);
                            count++;
                        }
                        else
                        {
                            Console.Write(count);
                            count++;
                        }
                    }
                }
                Console.WriteLine();
            }
            Console.ReadLine();
        }

    }

No comments: