Advertisement
Teodor92

MissCat2011

Nov 28th, 2012
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 KB | None | 0 0
  1. using System;
  2.  
  3. class MissCat2011
  4. {
  5.     static void Main()
  6.     {
  7.         int n = int.Parse(Console.ReadLine());
  8.         int[] cats = new int[11];
  9.         for (int i = 0; i < n; i++)
  10.         {
  11.             byte vote = byte.Parse(Console.ReadLine());
  12.             switch (vote)
  13.             {
  14.                 case 1: cats[1] = cats[1] + 1;
  15.                     break;
  16.                 case 2: cats[2] = cats[2] + 1;
  17.                     break;
  18.                 case 3: cats[3] = cats[3] + 1;
  19.                     break;
  20.                 case 4: cats[4] = cats[4] + 1;
  21.                     break;
  22.                 case 5: cats[5] = cats[5] + 1;
  23.                     break;
  24.                 case 6: cats[6] = cats[6] + 1;
  25.                     break;
  26.                 case 7: cats[7] = cats[7] + 1;
  27.                     break;
  28.                 case 8: cats[8] = cats[8] + 1;
  29.                     break;
  30.                 case 9: cats[9] = cats[9] + 1;
  31.                     break;
  32.                 case 10: cats[10] = cats[10] + 1;
  33.                     break;
  34.             }
  35.  
  36.         }
  37.         int bestCat = 0;
  38.         for (int i = 1; i <= 10; i++)
  39.         {
  40.             for (int j = i; j <= 10; j++)
  41.             {
  42.                 if (cats[j]>cats[bestCat])
  43.                 {
  44.                     bestCat = j;
  45.                 }
  46.                 else if (cats[j] == cats[bestCat] && j < bestCat)
  47.                 {
  48.                     bestCat = j;
  49.                 }
  50.             }
  51.         }
  52.         Console.WriteLine(bestCat);
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement