-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPalindrom.java
49 lines (31 loc) · 1.03 KB
/
Palindrom.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
38
39
40
41
42
43
44
45
46
47
48
49
import java.util.*;
public class Palindrom {
public static void main(String[] args) {
System.out.print("Enter Input : ");
Scanner sc = new Scanner(System.in);
int a1 = 121;
String a = sc.next(); // = "121"
int start=0;
int end=a.length()-1;
int c=0;
for(int i=0;i<a.length()-1;i++){
if(a.charAt(start) == ('-') && ((a.charAt(start+1)>= 0 && a.charAt(start+1)<=9 ))){
start++;
}
}
while(start<end){
if(a.charAt(start) != a.charAt(end)){
c=1;
break;
}
start++;
end--;
}
if(c==1){
System.out.println("The input is not palindrom.");
}
else{
System.out.println("The input is palindrom.");
}
}
}