-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ036.java
More file actions
35 lines (27 loc) · 857 Bytes
/
J036.java
File metadata and controls
35 lines (27 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//회문 검사 (palindrome)
import java.util.Scanner;
public class J036{
public static void main(String[] args){
J036 pStudio = new J036();
pStudio.J036();
}
public void J036(){
Scanner s = new Scanner(System.in);
String str;
String alp_str = "";
int count = 0;
str = s.nextLine();
str = str.toLowerCase();
for(int i = 0; i<str.length(); i++)
if(str.charAt(i) >= 'a' && str.charAt(i) <= 'z')
alp_str += str.charAt(i);
for(int i=0,j=alp_str.length()-1; i<alp_str.length()/2; i++,j--){
if(alp_str.charAt(i) != alp_str.charAt(j))
count = 1;
}
if(count == 0)
System.out.println("Yes");
else if(count == 1)
System.out.println("NO");
}
}