import java.util.Scanner;
public class HW {
private static Scanner input;
public static void main(String[] args) {
input = new Scanner(System.in);
System.out.print("请输入字符串");
String zifuchuan = input.nextLine();
System.out.println("字符串的长度为" + zifuchuan.length());
System.out.println(r(zifuchuan));
}
static boolean r(String zifuchuan) {
for (int i = 0; i < zifuchuan.length() - i - 1; i++) {
if (zifuchuan.charAt(i) == zifuchuan.charAt(zifuchuan.length() - 1
- i)) {
continue;
} else
return false;
}
return true;
}
}
判断是否为回文
最新推荐文章于 2024-02-27 18:44:40 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)