Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace _06._Max_Sequence_of_Equal_Elements_Veronika
- {
- class MaxSeqOfEqualElements
- {
- static void Main(string[] args)
- {
- int[] input = Console.ReadLine().
- Split(' ').Select(int.Parse).ToArray();
- int digit = 0;
- int max = 1;
- string equalElement = "";
- for (int i = 0; i < input.Length; i++)
- {
- int currentIndex = input[i];
- int longest = 0;
- for (int j = i; j < input.Length; j++)
- {
- if (input[i] == input[j])
- {
- longest++;
- if (max < longest)
- {
- max = longest;
- digit = currentIndex;
- }
- }
- else
- {
- break;
- }
- }
- }
- for (int i = 0; i < max; i++)
- {
- Console.Write(digit+ " ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment