Created
May 30, 2016 09:03
-
-
Save Nikola-Andreev/90a10613cedeea5268a1fe1782bdea57 to your computer and use it in GitHub Desktop.
6. Max Sequence of Equal Elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Numerics; | |
using System.Globalization; | |
using System.Text.RegularExpressions; | |
namespace Praktice | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
int[] array1 = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); | |
int start = 0; | |
int count = 0; | |
int max = 0; | |
for (int i = 0; i < array1.Length-1; i++) | |
{ | |
if (array1[i]==array1[i+1]) | |
{ | |
count++; | |
if (count > max) | |
{ | |
start = i - count; | |
max = count; | |
} | |
} | |
else | |
{ | |
count = 0; | |
} | |
} | |
for (int i = start+1 ; i <= start+max+1; i++) | |
{ | |
Console.Write(array1[i]+" "); | |
} | |
Console.WriteLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment