JuliaPetkova

Untitled

Jun 13th, 2017
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. sing System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _6_2_08_MostFrequentNumbers
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int[] array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  14.  
  15. int maxCount = 0;
  16. int number = 0;
  17.  
  18.  
  19. for (int i = 0; i < array.Length; i++)
  20. {
  21. int count = 0;
  22.  
  23. for (int j = i; j < array.Length; j++)
  24. {
  25. if (array[i] == array[j])
  26. {
  27. count++;
  28. }
  29. }
  30.  
  31. if (count > maxCount)
  32. {
  33. maxCount = count;
  34. number = array[i];
  35. }
  36. }
  37. Console.WriteLine(number);
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment