Advertisement
skipter

C# Equal Sequances of Elements in Array

Jun 23rd, 2017
138
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 _14.EqualElemtsInArray
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[] arrayElements = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  14.             bool IsEqual = false;
  15.             for (int cnt = 0; cnt < arrayElements.Length - 1; cnt++)
  16.             {
  17.                 if (arrayElements[cnt] == arrayElements[cnt + 1])
  18.                 {
  19.                     IsEqual = true;
  20.                 } else
  21.                 {
  22.                     IsEqual = false;
  23.                     break;
  24.                 }
  25.             }
  26.             if (IsEqual)
  27.             {
  28.                 Console.WriteLine("Yes");
  29.             } else
  30.             {
  31.                 Console.WriteLine("No");
  32.             }
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement