Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class MaximalSequence
- {
- static void InitializeArray(int[] arr)
- {
- for (int i = 0; i < arr.Length; i++)
- {
- Console.Write("Enter {0} element: ", i + 1);
- arr[i] = int.Parse(Console.ReadLine());
- }
- }
- static void Main()
- {
- int total = 0;
- Console.Write("Enter number of elements: ");
- total = int.Parse(Console.ReadLine());
- int[] array = new int[total];
- InitializeArray(array);
- int current = 0;
- int prev = 0;
- int count = 0;
- int maximalCount = 0;
- for (int i = 0; i < array.Length; i++)
- {
- current = array[i];
- if (i == 0)
- {
- prev = current;
- }
- else
- {
- prev = array[i - 1];
- }
- if (current == prev) count++;
- else count = 1;
- if (count > maximalCount)
- {
- maximalCount = count;
- }
- }
- Console.WriteLine(maximalCount);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement