Algorithm/SWEA

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

_cpdm_ 2021. 3. 26. 16:37
반응형


문제 이해

 

아이디어

 

코드

import java.util.*;
public class Solution {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int T= Integer.parseInt(sc.nextLine());
		for(int tc=1; tc<=T; ++tc) {
			String str = sc.nextLine();
			String str_rev="";
			for(int i=str.length()-1;i>=0;--i) {
				str_rev += str.charAt(i);
			}
			System.out.printf("#%d %d\n",tc,(str.equals(str_rev) ? 1 : 0));
		}
		sc.close();
	}
}

 

 


 

 

집사는개발자가되고파

 

choppadontbiteme.tistory.com

 

반응형