8. String to Integer (atoi)

来源:互联网 发布:软件产业基地停车收费 编辑:程序博客网 时间:2024/06/05 03:37
bool isPalindrome(int x) {    if (x < 0) return false;    else if(x == 0) return true;    int i = 1, j = 0;    while (true)    {        if (pow(10.0, i - 1) <= x && x < pow(10.0, i))            break;        else            i++;    }    while (j < i / 2)    {        if ((int)(x / pow(10.0, j)) % 10 != (int)(x / pow(10.0, i - j - 1)) % 10)        {            break;        }        j++;    }    return (j == i / 2);}
0 0