Advertisement
gabi11

Sets & Dictionaries Advanced - 04. Even Times

May 19th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.75 KB | None | 0 0
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Text.RegularExpressions;
  7.  
  8. namespace Advanced
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             int number = int.Parse(Console.ReadLine());
  15.  
  16.             var digits = new Dictionary<int, int>();
  17.  
  18.             for (int i = 0; i < number; i++)
  19.             {
  20.                 int digit = int.Parse(Console.ReadLine());
  21.  
  22.                 if (!digits.ContainsKey(digit))
  23.                 {
  24.                     digits[digit] = 0;
  25.                 }
  26.  
  27.                 digits[digit]++;
  28.  
  29.             }
  30.             Console.WriteLine(digits.First(x => x.Value % 2 == 0).Key);
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement