//一个代码一个代码打出来的,望采纳!
import java.util.Scanner;
public class test {
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("输入一串字符,以@结束:");
String str=input.nextLine();
while(str.charAt(str.length()-1)!='@'){
System.out.println("请以@结尾,请重新输入:");
str=input.nextLine();
}
IsHuiWen(str);
}
public static void IsHuiWen(String str){
String sonStr=str.substring(0, str.length()-1);
char[] ch1=sonStr.toCharArray();
char[]ch2=new char[ch1.length];
boolean yes=true;
for(int i=0;i
ch2[i]=ch1[ch1.length-1-i];
}
for(int i=0;i
if(ch1[i]!=ch2[i]){
yes=false;
break;
}
}
if(yes){
System.out.println("是回文序列");
}
else{
System.out.println("不是回文序列");
}
}
}