Advertisement
Venciity

[SoftUni C# exam preparation] 02.MissCat

Apr 9th, 2014
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.64 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. class MissCat
  5. {
  6.     static void Main()
  7.     {
  8.         int n = int.Parse(Console.ReadLine());
  9.         int[] catsScore = new int[11];
  10.         for (int i = 0; i < n; i++)
  11.         {
  12.             byte vote = byte.Parse(Console.ReadLine());
  13.             catsScore[vote]++;
  14.         }
  15.         int bestCatScore = int.MinValue;
  16.         int indexOfBestCat = 1;
  17.         for (int i = 1; i < 11; i++)
  18.         {
  19.             if (bestCatScore < catsScore[i])
  20.             {
  21.                 bestCatScore = catsScore[i];
  22.                 indexOfBestCat = i;
  23.  
  24.             }
  25.         }
  26.         Console.WriteLine(indexOfBestCat);
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement