#include "stdafx.h" int find_first_1(int n) { int index = 1; while( (n&1)==0 && index < 32) { n >>= 1; index <<= 1; } return index; } void find(int * arr, int len, int & num1, int & num2) { int temp = 0; for(int i=0;i<len;i++) temp ^= arr[i]; unsigned int index = find_first_1(temp); num1 = 0; num2 = 0; for(int i=0;i<len;i++) { if((arr[i]&index)==0) num1^=arr[i]; else num2^=arr[i]; } } int _tmain(int argc, _TCHAR* argv[]) { int num1,num2; int arr[] = {2,2,3,100,4,5,4,5}; find(arr,8,num1,num2); printf("%d %d\n",num1,num2); return 0; }