package suanfa;
import java.util.Scanner;
public class Palindrome {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("输入一个字符串: ");
String s=input.nextLine();
int low=0;
int high=s.length()-1;
boolean isPalindrome=true;
while(low<high){
if(s.charAt(low)!=s.charAt(high)){
isPalindrome=false;
break;
}
low++;
high--;
}
if(isPalindrome){
System.out.println("是回文");
}else{
System.out.println("不是回文");
}
}
}
import java.util.Scanner;
public class Palindrome {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("输入一个字符串: ");
String s=input.nextLine();
int low=0;
int high=s.length()-1;
boolean isPalindrome=true;
while(low<high){
if(s.charAt(low)!=s.charAt(high)){
isPalindrome=false;
break;
}
low++;
high--;
}
if(isPalindrome){
System.out.println("是回文");
}else{
System.out.println("不是回文");
}
}
}