Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
- using System;
- using System.IO;
- using System.Linq;
- using System.Collections.Generic;
- namespace Program
- {
- public class MaxSequenceOfEqualElements
- {
- public static void Main()
- {
- //2 1 1 2 3 3 2 2 2 1
- int[] a=Console.ReadLine().Split().Select(int.Parse).ToArray();
- int count=0;
- int num=0;
- int num1=0;
- int count1=0;
- int start=0;
- for(int i=0;i<a.Length-1;i++)
- {
- if(a[i]==a[i+1])
- {
- num=a[i];
- count++;
- }
- else if(a[i]!=a[i+1])
- {
- start=a[i+1];
- }
- for(int j =start;j<a.Length-1;j++)
- {
- if(a[j]==a[j+1])
- {
- num1=a[j];
- count1++;
- }
- if(count1>count)
- {
- num1=num;
- count1=count;
- break;
- }
- }
- }
- for(int i=0;i<count;i++)
- {
- Console.Write(num+" ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement