Advertisement
loter

Max Friquent Number

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