Java/SW Expert Academy

1989. 초심자의 회문검사

GLOWWW 2021. 1. 5. 16:14
package oSWExpertAcademy;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class D2_1989 {
    public static void main(String[]args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int count;
        try {
            count = Integer.parseInt(br.readLine());
            for(int i=1; i<=count; i++) {
                String words = br.readLine();
                StringBuilder rwords = new StringBuilder(words);
                rwords = rwords.reverse();
//                System.out.println(words);
//                System.out.println(rwords);
                System.out.print("#"+i+" ");
                if(words.equals(rwords.toString())) {
                    System.out.println(1);
                    continue;
                }else
                    System.out.println(0);
            }
        } catch (NumberFormatException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}