回文_函式

 avatar
user_3763047219
c_cpp
2 years ago
591 B
4
Indexable
Never
#define _CRT_SCURE_NO_WARNINGS
#include <iostream>

void isPalindrome(int x);

void isPalindrome(int x) {
    if (x < 0) {
        printf("false");
    }
    else {
        int x2 = x;
        int newx = 0;
        while (x >= 1) {
            newx = newx * 10 + x % 10;
            x = x / 10;
        }
        if (newx == x2) {
            printf("true");
        }
        else {
            printf("false");
        }
    }
    
}


#include <stdio.h>
int main() {
        int x;
        scanf("%d", &x);
        isPalindrome(x);
        return 0;
    }