/**
* Desc:
* An integer is a palindrome when it reads the same backward as forward. For example, 121 is palindrome while 123 is not.
*/
class Solution {
public boolean isPalindrome(int x) {
int y=0;
int temp=x;
while(temp>0){
int r=temp%10;
temp=temp/10;
y=y*10+r;
}
if(y==x){
return true;
}else{
System.out.println(y);
return false;
}
}
}
public class test {
public static void main(String[] args) {
int target = 121;
Solution solution = new Solution();
boolean status = solution.isPalindrome(target);
System.out.println(status);
}
}
【Palindrome Number】-1(Java)
于 2021-11-23 16:10:30 首次发布