Anonymous
public text v1 · immutableint hdist(int c[r],int a,int b)
{
int i;
int count=0;
int dist=c[a]^c[b];
for(i=0;i<n;i++) if(dist & (1<<i))count++;
printf("%d ",count);
return count;
}
Tried this, and it works here. Peter C.
#include <stdio.h>
int n = 8;
int r = 2;
int hdist(int c[r],int a,int b)
{
int i;
int count=0;
int dist=c[a]^c[b];
for(i=0;i<n;i++) if(dist & (1<<i)) count++;
printf("%d\n",count);
return count;
}
int main( int argc, char **argv )
{
int a[2] = { 0xF0, 0x00 };
hdist(a, 0, 1);
}