Advertisement
Stann

Problem 4 - Odd Number

Mar 5th, 2014
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 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 OddNumber
  8. {
  9. class OddNumber
  10. {
  11. static void Main(string[] args)
  12. {
  13. uint n = uint.Parse(Console.ReadLine());
  14. int counter = 1;
  15.  
  16. List<long> list = new List<long>();
  17. for (int i = 0; i < n; i++)
  18. {
  19. long num = long.Parse(Console.ReadLine());
  20.  
  21. list.Add(num);
  22. }
  23. for (int j = 0; j < n; j++)
  24. {
  25. for (int i = 1; i < list.Count; i++)
  26. {
  27.  
  28. if (list[0] == list[i])
  29. {
  30. counter++;
  31. }
  32.  
  33. }
  34. if(counter % 2 !=0 || counter == 1)
  35. {
  36.  
  37. Console.WriteLine(list[0]);
  38. break;
  39. }
  40. list.Remove(list[0]);
  41. counter = 1;
  42.  
  43. }
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement