(c language) determine whether a positive integer is a palindrome

(c language) determine whether a positive integer is a palindrome

A palindromic number means that reading the number from left to right is the same as reading it from right to left. For example: 1,101,1221 are palindrome numbers.

#include<stdio.h>
#include<stdlib.h>
int main(){
    
    
	int n,s,y=0;
	printf("请输入所要进行判断的数字:");
	scanf("%d",&n);
	s=n; 
	while(s>0){
    
    
		y=s%10+y*10;
		s=s/10;
	}
	if(y==n){
    
    
		printf("%d是回文数",n);
	}else{
    
    
		printf("%d不是回文数",n);
	} 
}

Guess you like

Origin blog.csdn.net/WuwuwuH_/article/details/113756974