Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Exercises
- {
- class Program
- {
- public static void Main(string[] args)
- {
- int[] arr = {1, 2, 2, 1, 2, 2, 2, 3, 3, 3, 3};
- int lenght = arr.Length;
- int tempNum = 0;
- int Num = 0;
- int tempCount = 0;
- int Count = 0;
- for (int i = 0; i < lenght; i++)
- {
- if (tempNum == arr[i]) tempCount++;
- else tempCount = 1;
- if (tempCount > Count)
- {
- Count = tempCount;
- Num = tempNum;
- }
- tempNum = arr[i];
- }
- for (int j = 0; j < Count; j++)
- {
- Console.Write(Num + " ");
- }
- Console.ReadKey(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement