package test;
import java.util.Scanner;
public class Huiw {
/**
* @param args
*/
public static void main(String[] args) {
Scanner scanner =new Scanner(System.in);
System.out.println("输入一个正整数");
int iIn=scanner.nextInt(); //接收输入的数字
int k=0,iB=iIn;
int[] A=new int[10];
for ( ;iB>0;){ //把数字拆分,放入数组
A[k++]=iB%10;
iB=iB/10;
//System.out.print(A[k]);
}
//System.out.println(k);
// for(int j=0;j
int i=0;
for(;i
System.out.println("NO");
break;}
}
// System.out.println(i);
// System.out.println(k);
if(i==k/2)
System.out.println("YES");
}
}
public static boolean isEchoWord(String word) {
for (int i = 0; i < word.length() + 1 / 2; i++) {
if (word.charAt(i) != word.charAt(word.length() - 1 - i)) {
return false;
}
}
return true;
}
public static void main(String args[]) throws IOException {
System.out.println("please input word:");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
for (String input = br.readLine(); !"exit".equals(input); input = br.readLine()) {
System.out.println(isEchoWord(input));
}
}
你可以用栈的方法试试,先入后出,然后判断