回文整数

/*************************************************************************
        > File Name: main.c
        > Author:
        > Mail:
        > Created Time: Tue 27 Oct 2020 04:49:20 PM CST
 ************************************************************************/

#include<stdio.h>

int isPalindrome(int x) {
    if (__builtin_expect(!!(x < 0), 0)) return 0;
    int y = 0, z = x;
    while (x) {
        y = y * 10 + x % 10;
        x /= 10;
    }
     return z == y;
}

int main() {
    int n;
    while (scanf("%d", &n) != EOF) {
        if (isPalindrome(n)) printf("YES!\n");
        else {
            printf("NO!\n");
        }
    }
    return 0;
}

©️2020 CSDN 皮肤主题: 深蓝海洋 设计师:CSDN官方博客 返回首页