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

Tuesday, June 16, 2015

Write a program of Water matrix

class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter the size of array");
            int num = int.Parse(Console.ReadLine());

            int[,] arr = new int[num, num];
            Console.WriteLine("The given format of your matrix: {0}", num * num);
            for (int i = 0; i < num; i++)
            {
                for (int j = 0; j < num; j++)
                {
                    arr[i, j] = int.Parse(Console.ReadLine());
                }
            }

            Console.WriteLine("Your matrix representation");
            for (int i = 0; i < num; i++)
            {
                for (int j = 0; j < num; j++)
                {
                    Console.Write(arr[i, j] + " ");
                }
                Console.WriteLine();
            }

            Console.WriteLine("your Water matrix");
            for (int i = num - 1; i >= 0; i--)
            {
                for (int j = 0; j < num; j++)
                {
                    Console.Write(arr[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
            Console.ReadLine();
        }
              
    }



 
Output:

No comments: