Advertisement
fbinnzhivko

EncodedAnswers

Apr 22nd, 2016
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. class EncodedAnswers
  4. {
  5.     static void Main()
  6.     {
  7.         int n = int.Parse(Console.ReadLine());
  8.         List<char> answers = new List<char>();
  9.         int[] counts = new int[4];
  10.  
  11.         for (int i = 0; i < n; i++)
  12.         {
  13.             uint qustion = uint.Parse(Console.ReadLine());
  14.             uint answer = qustion % 4;
  15.             char answerAsLetter = Convert.ToChar(97 + answer);
  16.             answers.Add(answerAsLetter);
  17.  
  18.             switch (answerAsLetter)
  19.             {
  20.                 case 'a': counts[0]++; break;
  21.                 case 'b': counts[1]++; break;
  22.                 case 'c': counts[2]++; break;
  23.                 case 'd': counts[3]++; break;
  24.             }
  25.         }
  26.         PrintAnswers(answers);
  27.         Console.WriteLine("Answer A: {0}", counts[0]);
  28.         Console.WriteLine("Answer B: {0}", counts[1]);
  29.         Console.WriteLine("Answer C: {0}", counts[2]);
  30.         Console.WriteLine("Answer D: {0}", counts[3]);
  31.     }
  32.     static void PrintAnswers(List<char> answers)
  33.     {
  34.         for (int i = 0; i < answers.Count; i++)
  35.         {
  36.             if (i < answers.Count - 1)
  37.             {
  38.                 Console.Write("{0} ", answers[i]);
  39.             }
  40.             else
  41.             {
  42.                 Console.WriteLine("{0}", answers[i]);
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement