Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class MaxSequenceOfEqualElements
- {
- static void Main()
- {
- Console.WriteLine("Please, insert the length of the array!");
- byte n = byte.Parse(Console.ReadLine());
- Console.WriteLine("Now the values:");
- //Read array
- int[] array = new int[n];
- for (int i = 0; i < n; i++)
- {
- array[i] = int.Parse(Console.ReadLine());
- }
- // Compair
- int count = 0;
- int maxCount = 0;
- int currentInt = 0;
- int bigInt = 0;
- for (int i = 0; i < array.Length - 1; i++)
- {
- if (array[i] == array[i + 1])
- {
- count++;
- currentInt = array[i];
- }
- else
- {
- count = 0;
- }
- if (count >= maxCount)
- {
- maxCount = count;
- bigInt = currentInt;
- }
- }
- // Print
- for (int i = 0; i <= maxCount; i++)
- {
- Console.Write(bigInt);
- }
- Console.WriteLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement