#include<stdio.h>
int findxor(int *a,int len)
{
int i=0,temp=0;
for(;i<len;i++)
{
temp=temp^a[i];
}
return temp;
}
int loc(int temp)
{
int count=1;
while(!(temp&1))
{
temp=temp>>1;
count++;
}
return count;
}
int isbit(int a,int n)
{
return (a>>(n))&1;
}
void findunique(int *a,int len)
{
int m=0,n=0,i,xor=0,location=0;
xor=findxor(a,len);
location=loc(xor);
for(i=0;i<len;i++)
{
if(isbit(a[i],location))
m=a[i] ^ m;
else
n=n ^ a[i];
}
printf("m=%d,n=%d",m,n);
}
void main()
{
int a[]={1,3,4,6,6,5,4,3,1,2};
findunique(a,10);
}
int findxor(int *a,int len)
{
int i=0,temp=0;
for(;i<len;i++)
{
temp=temp^a[i];
}
return temp;
}
int loc(int temp)
{
int count=1;
while(!(temp&1))
{
temp=temp>>1;
count++;
}
return count;
}
int isbit(int a,int n)
{
return (a>>(n))&1;
}
void findunique(int *a,int len)
{
int m=0,n=0,i,xor=0,location=0;
xor=findxor(a,len);
location=loc(xor);
for(i=0;i<len;i++)
{
if(isbit(a[i],location))
m=a[i] ^ m;
else
n=n ^ a[i];
}
printf("m=%d,n=%d",m,n);
}
void main()
{
int a[]={1,3,4,6,6,5,4,3,1,2};
findunique(a,10);
}