반응형
import java.util.Scanner;
public class palindrome {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T;
T=sc.nextInt();
sc.nextLine();
for(int test_case = 1; test_case <= T; test_case++)
{
String str = sc.nextLine();
int result = 1;
int len = str.length();
for (int i = 0; i < len / 2; i++) {
if (str.charAt(i) != str.charAt( len -1 - i)){
result = 0;
break;
}
}
System.out.println("#"+test_case +" "+ result);
}
}
}
반응형
'알고리즘' 카테고리의 다른 글
[SWEA][D2] 1954. 달팽이 숫자 Java (0) | 2025.06.03 |
---|---|
[SWEA][D2] 1959. 두 개의 숫자열 Java (0) | 2025.06.03 |
[SWEA][D2] 1961. 숫자 배열 회전 Java (0) | 2025.06.02 |
[SWEA][D2] 1966. 숫자를 정렬하자 Java (0) | 2025.06.02 |
[SWEA][D2] 1970. 쉬운 거스름돈 Java (1) | 2025.06.02 |