알고리즘/SwExpert recipe

SWEA 초심자의회문검사 [D2]

컵라면만두세트 2021. 2. 12. 17:00
package D2;

import java.util.Arrays;
import java.util.Scanner;

public class 초심자의회문검사 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		 
		
		for(int tc = 1; tc<=T; tc++) {
			String s = sc.next();
			boolean check = true;
			String arr[] = new String[s.length()];
			String arr2[] = new String[s.length()];
			for(int i =0; i<s.length(); i++) {	
				arr[i] = s.substring(i, i+1);
			}
			for(int i=0; i<s.length(); i++) {
				arr2[i] = arr[(arr.length-1-i)];
			}
			
			check = Arrays.equals(arr,arr2); // arrays.equls 반환값은 true, false
			if(check) {
				System.out.println("#" + tc + " " + 1);
			}else {
				System.out.println("#" + tc + " " + 0);
			}
		}
	}

}

'알고리즘 > SwExpert recipe' 카테고리의 다른 글

SWEA 가랏RC카 [D2]  (0) 2021.02.13
SWEA 어디에 단어가 들어갈수있을까 [D2]  (0) 2021.02.13
SWEA 새로운 불면증 치료 [D2]  (0) 2021.02.11
SWEA 지그재그 숫자 [D2]  (0) 2021.02.09
SWEA 암호문1 [D3]  (0) 2021.02.09