Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace MostFrequentNumbers
- {
- class Program
- {
- public static void Main(string[] args)
- {
- int[] array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- int start = 0;
- int end = 0;
- int bestStart = 0;
- int bestLenght = 0;
- int totalLenght = 0;
- int currentNumber = 0;
- int counter = 0;
- int bestCounter = 0;
- int leftMostPosition = 0;
- for (int currentElement = 0; currentElement < array.Length; currentElement++)
- {
- currentNumber = array[currentElement];
- for (int currentCheck = 0; currentCheck < array.Length; currentCheck++)
- {
- if (currentNumber == array[currentCheck])
- {
- counter++;
- }
- }
- if (counter > bestCounter)
- {
- bestCounter = counter;
- leftMostPosition = currentElement;
- }
- counter = 0;
- }
- Console.WriteLine(array[leftMostPosition]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment