package com.dengpf.HuiWen;
/**
* Created by kobe73er on 16/12/17.
*/
public class Solution {
public boolean isPalindrome(int x) {
String result = String.valueOf(x);
int start = 0;
int end = result.length() - 1;
while (start < end) {
if (result.charAt(start)!=result.charAt(end)){
return false;
}
start++;
end--;
}
return true;
}
public static void main(String args[]){
Solution solution = new Solution();
System.out.println(solution.isPalindrome(11));
}
}判断是否是回文数字
最新推荐文章于 2025-06-23 19:56:46 发布
本文介绍了一种用于判断整数是否为回文数的简单算法,并提供了完整的Java实现代码。该算法通过将整数转换为字符串并比较其首尾字符来确定其是否对称。
1198

被折叠的 条评论
为什么被折叠?



