#include <stdio.h> int is_palindromic(int num) { char _old = num; char _new = 0; while (num) { _new = _new * 10 + (num % 10); num = num / 10; } if (_new == _old) { return 1; } else { return 0; } } int main() { int num = 0; scanf("%d", &num); int ret = is_palindromic(num); if (ret == 1) { printf("%d 是回文数\n", num); } else { printf("%d 不是回文数\n", num); } system("pause"); return 0; }
时间: 2024-10-08 10:14:25