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;
- using System.Numerics;
- namespace Revision
- {
- class ContinueTest
- {
- static void Main()
- {
- string input = Console.ReadLine();
- string[] inputSplit = input.Split(' ');
- int[] numbers = new int[inputSplit.Length];
- for (int i = 0; i < numbers.Length; i++)
- {
- numbers[i] = int.Parse(inputSplit[i]);
- }
- int count = 1;
- int frequent = 0;
- int highestCount = 0;
- int mostFrequent = 0;
- for (int k = 0; k < numbers.Length; k++)
- {
- for (int l = k + 1; l < numbers.Length; l++)
- {
- if (numbers[k] == numbers[l])
- {
- count++;
- frequent = numbers[k];
- if (count > highestCount)
- {
- highestCount = count;
- mostFrequent = frequent;
- }
- }
- else
- {
- count = 1;
- }
- }
- count = 1;
- }
- if (mostFrequent == 0)
- {
- Console.WriteLine("{0}", numbers[0]);
- }
- else
- {
- Console.WriteLine(mostFrequent);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement