Advertisement
Guest User

Untitled

a guest
May 31st, 2016
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.62 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Exercises
  4. {
  5.     class Program
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             int[] arr = {1, 2, 2, 1, 2, 2, 2, 3, 3, 3, 3};
  10.             int lenght = arr.Length;
  11.             int tempNum = 0;
  12.             int Num = 0;
  13.             int tempCount = 0;
  14.             int Count = 0;
  15.  
  16.             for (int i = 0; i < lenght; i++)
  17.             {
  18.                 if (tempNum == arr[i]) tempCount++;
  19.                     else tempCount = 1;
  20.                 if (tempCount > Count)
  21.                 {
  22.                     Count = tempCount;
  23.                     Num = tempNum;                                 
  24.                 }
  25.                 tempNum = arr[i];
  26.             }
  27.            
  28.             for (int j = 0; j < Count; j++)
  29.             {
  30.                 Console.Write(Num + " ");
  31.             }
  32.            
  33.             Console.ReadKey(true);
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement