Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2018
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _01MaxOfEqualElements
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. List<int> input = Console.ReadLine()
  12. .Split()
  13. .Select(int.Parse)
  14. .ToList();
  15.  
  16. int maxNumber= 0;
  17. int maxCounter = 0;
  18.  
  19. foreach (var num1 in input)
  20. {
  21. int counter = 0;
  22. foreach (var num2 in input)
  23. {
  24. if (num1 == num2)
  25. {
  26. counter ++;
  27. }
  28. }
  29.  
  30. if (counter > maxCounter)
  31. {
  32. maxCounter=counter;
  33. maxNumber = num1;
  34. }
  35. }
  36.  
  37. for (int i = 0; i < maxCounter; i++)
  38. {
  39. System.Console.WriteLine("{0} ", maxNumber);
  40. }
  41.  
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement