Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace Most_Friquent_Number
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- int counter = 1;
- int countMax = -1;
- int numMax = -1;
- for (int i = 0; i < numbers.Length; i++)
- {
- if (numbers[i] != numMax)
- {
- for (int j = i + 1; j < numbers.Length; j++)
- {
- if (numbers[i] == numbers[j])
- {
- counter++;
- if (counter > countMax)
- {
- countMax = counter;
- numMax = numbers[i];
- }
- }
- }
- }
- counter = 1;
- }
- Console.WriteLine(numMax);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement