Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace ExamPreparation
- {
- class Startup
- {
- static void Main()
- {
- int[] numbers = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- int length = 1;
- int bestLength = 0;
- int bestNumber = 0;
- for (int i = 0; i < numbers.Length - 1; i++)
- {
- if (numbers[i] == numbers[i+1])
- {
- length++;
- }
- else
- {
- length = 1;
- }
- if (length > bestLength)
- {
- bestLength = length;
- bestNumber = numbers[i];
- }
- }
- for (int i = 0; i < bestLength; i++)
- {
- Console.Write($"{bestNumber} ");
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement