Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace Maximum_Sequence
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.  
  11.             int[] array = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
  12.            
  13.             int maxCount = 0;
  14.             int currCount = 0;
  15.  
  16.             for (int i = 0; i < array.Length; i++)
  17.             {
  18.                 currCount = 1;
  19.                 for (int j = i + 1; j < array.Length - 1; j++)
  20.                 {
  21.                     if (array[i] == array[j])
  22.                     {
  23.                         currCount++;
  24.                     }
  25.                     else
  26.                     {
  27.                         break;
  28.                     }
  29.                 }
  30.                 if (currCount > maxCount)
  31.                 {
  32.                     maxCount = currCount;
  33.                 }
  34.             }
  35.  
  36.             Console.WriteLine(maxCount);
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement