llllmz

导航

9. 回文数c

bool isPalindrome(int x) {
    char c[1000]={0};
    sprintf(c,"%d",x);
    int n=strlen(c);
    int head=0,tail=n-1;
    while(head<=tail){
        if(c[head]!=c[tail]) return false;
        head++;
        tail--;
    }
    return true;
}

结果:

posted on 2024-03-15 19:44  神奇的萝卜丝  阅读(20)  评论(0)    收藏  举报