Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
- Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
- using System;
- using System.IO;
- using System.Linq;
- using System.Collections.Generic;
- namespace CSharp_Shell
- {
- public static class Program
- {
- public static void Main()
- {
- int[] arr = Console.ReadLine()
- .Split()
- .Select(int.Parse)
- .ToArray();
- int count=0;
- int position = 0;
- int maxCount=0;
- for(int i=0; i<arr.Length-1;i++)
- {
- if(arr[i] == arr[i+1])
- {
- count++;
- if(maxCount<count)
- {
- position=i-count;
- maxCount=count;
- }
- }
- else
- {
- count = 0;
- }
- }
- for (int i = position+1; i<=position+ maxCount+1;i++)
- {
- Console.Write(arr[i] + " ");
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement