Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- //You are given a list of N integer numbers all but one of which appears an even number of times.
- //Write a program to find the one integer which appears an odd number of times.
- //Input
- //The input data is being read from the console.
- //The number N is written on the first input line.
- //On each of the following N lines there is one integer number written – the consequent number from the given list of numbers.
- //The input data will always be valid and in the format described. There is no need to check it explicitly.
- //Output
- //The output data must be printed on the console.
- //On the only output line you must print the integer from the list which appears an odd number of times.
- //Constraints
- //• N will be positive odd integer number between 1 and 99 999, inclusive.
- //• All of the numbers in the list will be integer numbers between -9 223 372 036 854 775 808
- //and 9 223 372 036 854 775 807, inclusive.
- class Program
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- long answer = 0;
- long num;
- for (int i = 0; i < n; i++)
- {
- num = long.Parse(Console.ReadLine());
- answer ^= num;
- }
- Console.WriteLine(answer);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement