判断一个数是否是回文数
回文数:121
#include <stdio.h> int main() { int val; int sum = 0; printf("请输入val:\n"); scanf("%d",&val); int m = val; while (m){ sum = sum * 10 + m % 10; m /= 10; } if(val == sum){ printf("yes \n"); } else{ printf("no \n"); } return 0; }
回文数:121
#include <stdio.h> int main() { int val; int sum = 0; printf("请输入val:\n"); scanf("%d",&val); int m = val; while (m){ sum = sum * 10 + m % 10; m /= 10; } if(val == sum){ printf("yes \n"); } else{ printf("no \n"); } return 0; }