Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int counter = 1;
- int maxCounter = 0;
- int[] numbersArray = new int[n];
- int num = 0;
- for (int i = 0; i < n; i++)
- {
- numbersArray[i] = int.Parse(Console.ReadLine());
- }
- Array.Sort(numbersArray);
- if (n == 1)
- {
- num = numbersArray[0];
- }
- for (int i = 0; i < n - 1; i++)
- {
- if (numbersArray[i] == numbersArray[i + 1])
- {
- counter++;
- }
- else
- {
- counter = 0;
- }
- if (counter > maxCounter)
- {
- maxCounter = counter;
- num = numbersArray[i];
- }
- }
- Console.WriteLine(num);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment