public static boolean isPalindrome(int x) { if (x < 0) return false; String str = x + ""; int low = 0; int high = str.length() - 1; while (low < high) { if (str.charAt(low) == str.charAt(high)) { low++; high--; } else { return false; } } return true; }
Java实现回文数
最新推荐文章于 2024-09-01 15:30:33 发布