判断是否为回文数
1 # include <stdio.h> 2 3 int main(void) 4 { 5 int val; //存放待判断的数字 6 int m; 7 int sum = 0; 8 9 printf("请输入您需要判断的数字: "); 10 scanf("%d", &val); 11 12 m = val; 13 while (m) 14 { 15 sum = sum * 10 + m%10; 16 m /= 10; 17 } 18 19 if (sum == val) 20 printf("Yes!\n"); 21 else 22 printf("No!\n"); 23 24 return 0; 25 }
时间: 2024-12-28 16:30:00