Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- class Program
- {
- static void Main()
- {
- int[] numbers = Console.ReadLine()
- .Split(" ", StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse)
- .ToArray();
- int occurence = 1;
- int biggestOccurence = 0;
- int mostCommonNumber = 0;
- for (int i = 0; i < numbers.Length; i++)
- {
- int previous = numbers[i];
- for (int j = i + 1; j < numbers.Length - 1; j++)
- {
- int current = numbers[j];
- if (previous == current)
- {
- occurence++;
- if (occurence > biggestOccurence)
- {
- biggestOccurence = occurence;
- mostCommonNumber = current;
- }
- }
- else
- {
- occurence = 1;
- }
- }
- }
- Console.WriteLine(mostCommonNumber);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement