Find the number from an array which is not repeated twice. C++
Here is the Code :
Thanks
#include <iostream>
#include <conio.h>
using namespace std;
void main()
{
int arr[] = { 1, 2, 3, 4, 5, 6, 6, 7, 8, 7, 8, 1, 4, 2,3 };
int result = 0;
int len = sizeof(arr) / sizeof(int);
for (int index = 0; index < len; ++index)
{
result ^= arr[index];
}
cout << result;
_getch();
}
Thanks

Comments
Post a Comment