mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-22 21:41:59 +03:00
32 lines
542 B
C
32 lines
542 B
C
|
#include <stdio.h>
|
||
|
|
||
|
int is_palindromic(unsigned int n)
|
||
|
{
|
||
|
unsigned int reversed = 0, t = n;
|
||
|
|
||
|
while (t>0)
|
||
|
{
|
||
|
reversed = 10 * reversed + (t % 10);
|
||
|
t /= 10;
|
||
|
}
|
||
|
return reversed == n;
|
||
|
}
|
||
|
|
||
|
int main(void)
|
||
|
{
|
||
|
unsigned int i, j, max = 0;
|
||
|
for (i = 100; i <= 999; i++)
|
||
|
{
|
||
|
for (j = 100; j <= 999; j++)
|
||
|
{
|
||
|
unsigned int p = i * j;
|
||
|
if (is_palindromic(p) && p > max)
|
||
|
{
|
||
|
max = p;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
printf("%u\n", max);
|
||
|
return 0;
|
||
|
}
|