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.Max_Sequence_of_Equal_Elements
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> nums = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
- int length = 1;
- int maxLength = 1;
- int position = 0;
- for (int i = 0; i < nums.Count; i++)
- {
- if (i > 0 && nums[i] == nums[i - 1])
- {
- length++;
- }
- else
- {
- length = 1;
- }
- if (maxLength < length)
- {
- maxLength = length;
- position = i+1 -maxLength;
- }
- }//end of for
- //Console.WriteLine(maxLength);
- //Console.WriteLine(position);
- for (int i = position; i < position + maxLength; i++)
- {
- Console.Write(nums[i] + " ");
- }
- Console.WriteLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement