Advertisement
xellscream

EqualElementsOfSequence

Jan 9th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. class EqualElementsOfSequence
  4. {
  5.     static void Main()
  6.     {
  7.         int a, b, c, count, maxCount, current;
  8.  
  9.         Console.Write("Enter size of the array: ");
  10.         int num = int.Parse(Console.ReadLine());
  11.         int[] arr = new int[num];
  12.  
  13.         count = 1;
  14.         maxCount = 0;
  15.  
  16.         for (int indexOne = 0, indexTwo = 1; indexTwo < num; indexOne += 2, indexTwo += 2)
  17.         {
  18.             a = arr[indexOne];
  19.             b = arr[indexTwo];
  20.             if (a == b)
  21.             {
  22.                 count++;
  23.                 if (count > maxCount)
  24.                 {
  25.                     maxCount = count;
  26.                 }
  27.                 else
  28.                 {
  29.                     continue;
  30.                 }
  31.             }
  32.             else
  33.             {
  34.                 count = 1;
  35.             }
  36.         }
  37.  
  38.         Console.Write("The biggest sequence is { ");
  39.         for(int index = 0; index < maxCount;index++)
  40.         {
  41.             Console.Write("{0} ",a);
  42.         }
  43.         Console.WriteLine("}    with {0} elements.", maxCount);
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement