#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];
}
}
时间: 2024-10-12 20:52:24