Advertisement
YavorGrancharov

Most_Frequent_Number(70%)

Oct 13th, 2017
107
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.Linq;
  3.  
  4. namespace Most_Frequent_Number
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int[] arr = Console.ReadLine()
  11.                 .Split(' ')
  12.                 .Select(int.Parse)
  13.                 .ToArray();
  14.  
  15.             int freq = 0;
  16.             int current = 0;
  17.  
  18.             for (int i = 0; i < arr.Length; i++)
  19.             {
  20.                 freq = arr[0];
  21.                 current = arr[i];
  22.                 if (current == freq)
  23.                 {
  24.                     freq = current;
  25.                     break;
  26.                 }
  27.             }
  28.             Console.WriteLine(freq);
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement