Advertisement
sylviapsh

Miss Cat

Dec 27th, 2012
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.84 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. class MissCat
  4. {
  5.   static void Main()
  6.   {
  7.     //Telerik Academy
  8.     //There are two things that cats love most: 1) sleeping and 2) attending beauty contests. The most important thing for each female cat is the contest “Miss Cat”. There are always ten cats that participate in the final round of the contest, numbered 1 to 10.
  9.   //The jury of the contest consists of N people who subjectively decide which cat to vote for. In other words each person votes for just 1 cat that he has most liked, or from whose owner he has received the biggest bribe. The winner of the contest is the cat that has gathered most votes. If two cats have equal votes, the winner of the contest is the one whose number is smaller.
  10.  
  11.     int jurySize = int.Parse(Console.ReadLine());
  12.     int vote = 0,
  13.          missVote = 0;
  14.     int [] voteArray = new int [10];
  15.  
  16.     for (int voteCounter = 0; voteCounter < jurySize; voteCounter++)
  17.     {
  18.       vote = int.Parse(Console.ReadLine());
  19.       switch (vote)
  20.       {
  21.         case 1: voteArray[0] += 1;
  22.           break;
  23.         case 2: voteArray[1] += 1;
  24.           break;
  25.         case 3: voteArray[2] += 1;
  26.           break;
  27.         case 4: voteArray[3] += 1;
  28.           break;
  29.         case 5: voteArray[4] += 1;
  30.           break;
  31.         case 6: voteArray[5] += 1;
  32.           break;
  33.         case 7: voteArray[6] += 1;
  34.           break;
  35.         case 8: voteArray[7] += 1;
  36.           break;
  37.         case 9: voteArray[8] += 1;
  38.           break;
  39.         case 10: voteArray[9] += 1;
  40.           break;
  41.         default:
  42.           break;
  43.       }
  44.  
  45.     }
  46.     missVote = voteArray.Max();
  47.  
  48.     for (int indexedVotes = 0; indexedVotes < 10; indexedVotes++)
  49.     {
  50.       if (voteArray[indexedVotes] == missVote)
  51.       {
  52.         Console.WriteLine(indexedVotes + 1);
  53.         break;
  54.       }
  55.     }
  56.   }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement