import java.util.*;
public class forth2 {
public static void main(String[] args) {
Scanner input =new Scanner(System.in);
System.out.print("enter a string: ");
String s=input.nextLine();
int low =0;
int high=s.length()-1;
boolean isp=true;
while(low<high)
{
if(s.charAt(low)!=s.charAt(high))
{
isp=false;
break;
}
low++;
high--;
}
if(isp)
System.out.println(s +"is a palindrome");
else
System.out.println(s +"is not");
}
}
java:判断字符串是不是回文字符串
最新推荐文章于 2023-05-08 22:57:11 发布