Advertisement
Guest User

Untitled

a guest
May 23rd, 2016
983
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. class Program
  5. {
  6.     static void Main()
  7.     {
  8.         int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
  9.         int maxCount = 0;
  10.         int maxStart = 0;
  11.         int currentCount = 1;
  12.         int currentStart = 0;
  13.         for (int i = 1; i < array.Length; i++)
  14.         {
  15.             if (array[i]==array[i-1])
  16.             {
  17.                 currentCount++;
  18.                 if (currentCount > maxCount) { maxCount = currentCount; maxStart = currentStart; }
  19.             }
  20.             else
  21.             {
  22.                 currentCount = 1;
  23.                 currentStart = i;
  24.             }
  25.         }
  26.         int[] result = array.Skip(maxStart).Take(maxCount).ToArray();
  27.         Console.WriteLine(string.Join(" ", result));
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement