Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ListsExercises
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<int> nums = Console.ReadLine()
- .Split()
- .Select(int.Parse)
- .ToList();
- int maxCounter = 0;
- int maxNumber = 0;
- foreach (var num1 in nums)
- {
- int counter = 0;
- foreach (var num2 in nums)
- {
- if (num1 == num2)
- {
- counter++;
- }
- }
- if (maxCounter < counter)
- {
- maxCounter = counter;
- maxNumber = num1;
- }
- }
- for (int i = 0; i < maxCounter; i++)
- {
- Console.Write($"{maxNumber} ");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement