nKolchakoV

Untitled

Apr 22nd, 2014
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _08.Majorant
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int[] array = new int[] { 2, 3, 2, 3, 2, 3, 4, 3, 3 };
  14.             int occurs = (array.Length / 2) + 1;
  15.  
  16.             for (int i = 0; i < array.Length; i++)
  17.             {
  18.                 if (array.ToList().FindAll(x => x == array[i]).Count >= occurs)
  19.                 {
  20.                     Console.WriteLine(array[i]);
  21.                     return;
  22.                 }
  23.             }
  24.             Console.WriteLine("doesnt exist");
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment