skipter icon

C# Array Symmetry

skipter | PRO | 06/23/17 12:58:14 PM UTC | 0 ⭐ | 365 👁️ | Never ⏰ | []
C# |

850 B

|

None

|

0 👍

/

0 👎

using System;
namespace _16.ArraySymmetry
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] firstArray = Console.ReadLine().Split(' ');           
            bool IsSymmetrical = false;
            int n = firstArray.Length / 2;
 
            for (int cnt = 0; cnt < n; cnt++)
            {
               if (firstArray[cnt] == firstArray[firstArray.Length - 1 - cnt])
                    {
                        IsSymmetrical = true;
                    } else
                    {
                        IsSymmetrical = false;
                    break;
                    }
            }
            if (IsSymmetrical)
            {
                Console.WriteLine("Yes");
            } else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Comments