Advertisement
4valeri

Miss_Cat_2011

Feb 16th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.88 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 Problem_2___Miss_Cat_2011
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int numberOfCats = int.Parse(Console.ReadLine());
  14.             int[] cats = new int[11];
  15.  
  16.             for (int i = 0; i < numberOfCats; i++)
  17.             {
  18.                 int catNUmber = int.Parse(Console.ReadLine());
  19.                 cats[catNUmber]++;
  20.             }
  21.  
  22.             int bestCat = 0;
  23.             int bestCatVotes = 0;
  24.  
  25.             for (int i = 1; i <= 10; i++)
  26.             {
  27.                 if (cats[i] >= bestCatVotes)
  28.                 {
  29.                     bestCat = i;
  30.                     bestCatVotes = cats[i];
  31.                 }
  32.             }
  33.  
  34.             Console.WriteLine(bestCat);
  35.  
  36.  
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement