Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _1.MaxSequenceOfEqualElements
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
- var len = 1;
- var maxLen = 1;
- var maxNumbers = 0;
- for (int position = 0; position < numbers.Count - 1; position++)
- {
- if (numbers[position] == numbers[position + 1])
- {
- len++;
- if (len > maxLen)
- {
- maxLen = len;
- maxNumbers = numbers[position];
- }
- }
- else
- {
- len = 1;
- }
- }
- if (maxLen == 1)
- {
- maxNumbers = numbers[0];
- Console.WriteLine(maxNumbers);
- }
- else
- {
- for (int i = 0; i < maxLen; i++)
- {
- Console.Write(maxNumbers + " ");
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement