文章标题

来源:互联网 发布:mac白屏很久 编辑:程序博客网 时间:2024/06/06 04:02

第四题

Largest palindrome product

int is_huiwen(int x){    int high = pow(10, floor(log10(x)));    int low;    while(high > 0)    {        low = x % 10;        int high1 = x / high;        if(high1 != low)            return 0;        x %= high;        x /= 10;        high /= 100;    }    return 1;}void example4(){    bool flag = 0;    int maxm = 1;    for(int i = 999; i >= 100; i--)    {        for(int j = i; j >= 100; j--)        {            if(is_huiwen(i * j))            {                if(i * j > maxm)                    maxm = i * j;            }        }    }    printf("%d\n", maxm);}