Advertisement
stefanpu

MissCat

Dec 14th, 2012
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.72 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 _2.MissCat
  8. {
  9.     class MissCat
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             List<int> votes = new List<int>() { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  15.            
  16.             for (int i = 1; i <= n; i++)
  17.             {
  18.                 int vote = int.Parse(Console.ReadLine());
  19.                 votes[vote - 1]++;
  20.             }
  21.  
  22.             //index is zero based, so we have to add 1.
  23.             int indexOfWinner = votes.IndexOf(votes.Max()) + 1;
  24.             Console.WriteLine(indexOfWinner);
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement