I wrote a program to find the largest palindromic number one could produce as the product of two three digit numbers.
Code:
int main (void)
{
int i, j, z;
int num;
char buf[6];
char test[6];
for(i=100; i<=999; i++)
{
for(j=100; j<=999; j++)
{
num = i * j;
sprintf(buf, "%d", num);
for(z=0; z<=6; z++)
test[z]=buf[z];
int len=strlen(buf);
for(z=0; z<len/2;z++)
{
test[z]^=test[len-z-1];
test[len-z-1]^=test[z];
test[z]^=test[len-z-1];
}
/*puts(buf);*/
/*puts(test);*/
/*printf("\n");*/
if(test == buf)
puts(buf);
}
}
return 0;
}
I'm having problems withe the part. I know the program produces the correct answer (906609), but when I run it, nothing ever ends up being printed. Should I be comparing the two arrays differently?