-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
37 lines (31 loc) · 884 Bytes
/
Main.java
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
36
37
import java.io.*;
class Solution {
public boolean isPalindrome(int x) {
int y, z;
if (x < 0) {
return false;
}
z = x;
y = 0;
while (x>0) {
y = y*10 + x%10;
x /= 10;
}
return (y == z);
}
}
public class Main {
public static String booleanToString(boolean input) {
return input ? "True" : "False";
}
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String line;
while ((line = in.readLine()) != null) {
int x = Integer.parseInt(line);
boolean ret = new Solution().isPalindrome(x);
String out = booleanToString(ret);
System.out.print(out);
}
}
}