Advertisement
grubcho

Equal sequence of elements in array

Jun 20th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 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 Equal_Sequence_of_Elements_in_Array
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string[] inputArray = Console.ReadLine().Split(' ');
  14.             int[] array = new int[inputArray.Length];
  15.             int countEqual = 0;
  16.             for (int i = 0; i < array.Length; i++)
  17.             {
  18.                 array[i] = int.Parse(inputArray[i]);
  19.  
  20.                 if (i != 0)
  21.                 {
  22.                     if (array[i - 1] == array[i])
  23.                     {
  24.                         countEqual++;
  25.                     }
  26.                 }
  27.  
  28.             }
  29.             if (countEqual == array.Length - 1)
  30.             {
  31.                 Console.WriteLine("Yes");
  32.             }
  33.             else
  34.             {
  35.                 Console.WriteLine("No");
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement