Advertisement
skipter

C# Array Symmetry

Jun 23rd, 2017
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.85 KB | None | 0 0
  1. using System;
  2. namespace _16.ArraySymmetry
  3. {
  4.     class Program
  5.     {
  6.         static void Main(string[] args)
  7.         {
  8.             string[] firstArray = Console.ReadLine().Split(' ');          
  9.             bool IsSymmetrical = false;
  10.             int n = firstArray.Length / 2;
  11.  
  12.             for (int cnt = 0; cnt < n; cnt++)
  13.             {
  14.                if (firstArray[cnt] == firstArray[firstArray.Length - 1 - cnt])
  15.                     {
  16.                         IsSymmetrical = true;
  17.                     } else
  18.                     {
  19.                         IsSymmetrical = false;
  20.                     break;
  21.                     }
  22.             }
  23.             if (IsSymmetrical)
  24.             {
  25.                 Console.WriteLine("Yes");
  26.             } else
  27.             {
  28.                 Console.WriteLine("No");
  29.             }
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement