Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- public class Max_Sequence_of_Equal_Elements
- {
- public static void Main()
- {
- int[]arr = Console.ReadLine()
- .Split().Select(int.Parse).ToArray();
- int maxSeqSize = 1;
- int tempSeqSize = 1;
- int output = 0;
- for(int i = 0; i < arr.Length - 1;i++)
- {
- if (arr[i] == arr[i + 1])
- {
- tempSeqSize++;
- if (tempSeqSize > maxSeqSize)
- {
- maxSeqSize = tempSeqSize;
- output = arr[i];
- }
- }
- else
- {
- tempSeqSize = 1;
- }
- if(maxSeqSize == 1)
- {
- output = arr[0];
- }
- }
- for(int i = 0; i < maxSeqSize; i++)
- {
- Console.Write(output + " ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement