본문 바로가기

Algorithm/Baekjoon

[백준_JAVA] 10988 팰린드롬인지 확인하기

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int result = 1;
		String word = sc.next();
		
		for(int i = 0; i < word.length(); i++) {
			char A = word.charAt(i);
			char B = word.charAt(word.length()-1-i);
			if(A != B)
				result = 0;
		}
		System.out.println(result);
		sc.close();
	}
}

'Algorithm > Baekjoon' 카테고리의 다른 글