Advertisement
Aborigenius

ArraySymmetry

Jun 16th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ArraySymmetry
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string N = Console.ReadLine();
  14.             string[] MyArray = N.Split(' ').ToArray();
  15.  
  16.             bool symmetric = true;
  17.             int index = MyArray.Length - 1;
  18.             for (int i = 0; i < MyArray.Length / 2; i++)
  19.             {
  20.                 if (MyArray[i] != MyArray[index])
  21.                 {
  22.                     symmetric = false;
  23.                     break;
  24.                 }
  25.                 index--;
  26.             }
  27.             if (symmetric == true)
  28.             {
  29.                 Console.WriteLine("Yes");
  30.             }
  31.             else
  32.             {
  33.                 Console.WriteLine("No");
  34.             }
  35.  
  36.  
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement