simonradev

ЕЙ ГО ВЕ

Nov 9th, 2016
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace MostFrequentNumbers
  5. {
  6. class Program
  7. {
  8. public static void Main(string[] args)
  9. {
  10. int[] array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  11.  
  12. int start = 0;
  13. int end = 0;
  14. int bestStart = 0;
  15. int bestLenght = 0;
  16. int totalLenght = 0;
  17.  
  18. int currentNumber = 0;
  19. int counter = 0;
  20. int bestCounter = 0;
  21. int leftMostPosition = 0;
  22. for (int currentElement = 0; currentElement < array.Length; currentElement++)
  23. {
  24. currentNumber = array[currentElement];
  25.  
  26. for (int currentCheck = 0; currentCheck < array.Length; currentCheck++)
  27. {
  28. if (currentNumber == array[currentCheck])
  29. {
  30. counter++;
  31. }
  32. }
  33.  
  34. if (counter > bestCounter)
  35. {
  36. bestCounter = counter;
  37. leftMostPosition = currentElement;
  38. }
  39. counter = 0;
  40. }
  41.  
  42. Console.WriteLine(array[leftMostPosition]);
  43.  
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment