#include <stdio.h>
int main ()
{
void function (int * str, int size, int *p1, int *p2);
int i = 0;
int NUM1 = 0, num2 = 0;
int arr[10] = {0};
int len = sizeof (arr)/sizeof (arr[0]);
for (i = 0; i < len; i++)
{
scanf ("%d", &arr[i]);
}
function (arr, len,&num1,&num2);
printf ("%d%d", NUM1, num2);
printf ("\ n");
System ("pause");
return 0;
}
void function (int * str, int size,int *p1,int *P2)
{
int i = 0,signal = 0,ret=0;
for (i = 0; i < size; i++)
{
RET ^= Str[i];
}
for (i = 0; i < 8 * sizeof (int); i++)
{
if (ret >> i) & 1 = = 1)
{
signal = i;
Break
}
}
for (i = 0; i < size; i++)
{
if ((Str[i] >> signal) & 1 = = 1)
*P1 ^= Str[i];
Else
*P2 ^= Str[i];
}
}
This article is from the "0-point Time" blog, please make sure to keep this source http://10741764.blog.51cto.com/10731764/1713975
Only two numbers in an array are different, other numbers are paired, and the following code can find and output the different two numbers in the array