【Java】判断回文数

520 ワード

import java.util.Scanner;

public class test52 {
	public static void main(String args[]) {
		char s1,s2;
		Scanner in = new Scanner(System.in);
		String str = in.nextLine();
		int len = str.length();
		int i=0,j=len-1,flag=0;
		for(i=0;i<=len/2;i++)
		{
			flag = 1;
			s1=str.charAt(i);
			s2=str.charAt(j);
			if(j >= len/2)
				j--;
			if(s1 != s2)
			{
				flag = 0;
				System.out.println("no");
				break;
			}		
		}
		if(flag == 1)
			System.out.println("yes");
	}
}