Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace MostFrequentNumber
- {
- class MainClass
- {
- public static void Main(string[] args)
- {
- int[] arr = Console.ReadLine()
- .Split(' ')
- .Select(int.Parse).ToArray();
- int[] counters = new int[arr.Length];
- int countMax = 0;
- int numMax = 0;
- for (int i = 0; i < arr.Length; i++)
- {
- for (int j = i; j < arr.Length; j++)
- {
- if ( arr[i] == arr[j] )
- {
- counters[i]++;
- if (counters[i] > countMax)
- {
- countMax = counters[i];
- numMax = arr[i];
- }
- }
- }
- }
- Console.WriteLine(numMax);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement