import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()){ String s = scanner.next(); System.out.println(new StringBuilder(s).reverse().toString().equals(s)?"Yes!":"No!"); } } }
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { String s = scanner.nextLine(); int i = 0; int j = s.length() - 1; while (i <= j) { if (s.charAt(i) == s.charAt(j)) { i++; j--; } else break; } System.out.println(i > j ? "Yes!" : "No!"); } } }
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); while(sc.hasNext()){ String str = sc.nextLine(); StringBuilder sb = new StringBuilder(str); if(sb.toString().equals(sb.reverse().toString())){ System.out.println("Yes!"); }else{ System.out.println("No!"); } } } }
用Eclipse完全没错,提交到网站却出错······ public class Main { public void doSome(String string){ if(string.length()%2!=0){ int record1=0; for(int i=0;i<string.length()/2;i++){ if(string.charAt(i)==string.charAt(string.length()-i-1)){ record1++; } } if(record1==string.length()/2){ System.out.println("Yes!"); }else{ System.out.println("No!"); } }else{ int record2=0; for(int i=0;i<=string.length()/2-1;i++){ if(string.charAt(i)==string.charAt(string.length()-i-1)){ record2++; } } if(record2==string.length()/2){ System.out.println("Yes!"); }else{ System.out.println("No!"); } } } public static void main(String[] args) { Scanner s=new Scanner(System.in); String input; Main m=new Main(); while(true){ input=s.nextLine(); m.doSome(input); } } }
import java.util.Scanner;
public class Main {
public static void main(String[] args) { Scanner sc=new Scanner(System.in); while(sc.hasNext()){ String s=sc.nextLine(); boolean b=true; for(int i=0;i<s.length()/2;i++){ if(s.charAt(i)!=s.charAt(s.length()-1-i)){ b=false; break; } } if(b){ System.out.println("Yes!"); }else{ System.out.println("No!"); } } sc.close(); }
}
import org.omg.CORBA.PUBLIC_MEMBER;
}//头尾同时比较即可
}
import java.util.*; public class Main{ public static void main(String[] args){ Scanner in=new Scanner(System.in); while(in.hasNext()){ String str=in.nextLine(); StringBuilder sb=new StringBuilder(str); String s=sb.reverse().toString(); if(str.equals(s)) System.out.println("Yes!"); else System.out.println("No!"); } } }
public class Main {
public static void main(String[] args) {
String a = null;
StringBuffer sb = null;
Scanner in = new Scanner(System.in);
while(in.hasNext()){
a = in.nextLine();
sb = new StringBuffer(a);
sb = sb. reverse() ;
if(a.compareTo(sb.toString()) == 0)
System.out.println("Yes!");
else
System.out.println("No!");
}
in.close();
}