Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication4
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int index = 1;
- List<string> array = new List<string>();
- string input = Console.ReadLine();
- array.Add(input);
- while (index < n)
- {
- input = Console.ReadLine();
- array.Add(input);
- index++;
- }
- string currentBestString = array[0];
- int currentBestNumber = 0;
- int counter = 0;// counts the occurences
- int countNumbers = 0;// counts the number of the numbers
- while (countNumbers < n)
- {
- string m = array[countNumbers];
- for (int i = 0; i < n; i++)
- {
- if (m == array[i])
- {
- counter++;
- }
- }
- if (counter > currentBestNumber)
- {
- currentBestNumber = counter;
- currentBestString = m;
- }
- counter = 0;
- countNumbers++;
- }
- Console.WriteLine(currentBestNumber);
- int writerConsole = 0;
- do
- {
- Console.WriteLine(currentBestString);
- writerConsole++;
- } while (writerConsole < currentBestNumber);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement