Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class EqualElementsOfSequence
- {
- static void Main()
- {
- int a, b, count, maxCount, current;
- Console.Write("Enter size of the array: ");
- int num = int.Parse(Console.ReadLine());
- int[] arr = new int[num];
- count = 1;
- maxCount = 0;
- for (int indexOne = 0, indexTwo = 1; indexTwo < num; indexOne += 2, indexTwo += 2)
- {
- a = arr[indexOne];
- b = arr[indexTwo];
- if (a == b)
- {
- count++;
- if (count > maxCount)
- {
- maxCount = count;
- current = arr[indexOne];
- }
- else
- {
- continue;
- }
- }
- else
- {
- count = 1;
- }
- }
- int printed = current;
- Console.Write("The biggest sequence is { ");
- for(int index = 0; index < maxCount;index++)
- {
- Console.Write("{0} ",current);
- }
- Console.WriteLine("} with {0} elements.", maxCount);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement