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;
- namespace MostFrequentNumber
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] input =
- Console.ReadLine().Split().Select(int.Parse).ToArray();
- Dictionary<int, int> occurrences = new Dictionary<int, int>();
- for (int i = 0; i < input.Length; i++)
- {
- if (!occurrences.ContainsKey(input[i]))
- {
- occurrences[input[i]] = 1;
- }
- else
- {
- occurrences[input[i]]++;
- }
- }
- var sorted = occurrences.OrderByDescending(x => x.Value).ToArray();
- foreach (var o in sorted)
- {
- Console.WriteLine(o.Key);
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement