-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathS.java
More file actions
36 lines (29 loc) · 791 Bytes
/
S.java
File metadata and controls
36 lines (29 loc) · 791 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
36
public class S{
public static long reverse(int num) {
int originalno = num;
if(num < 0){
num = -num;
}
long reverse = 0;
while (num > 0) {
int a = num % 10;
reverse = a + reverse*10;
num = num/10;
}
if ( reverse < 2147483647 && reverse > -2147483648) {
if(originalno < 0 )
return -reverse;
else
return reverse;
}
else{
return 0;
}
}
public static void main(String[] args){
long a = reverse(123);
System.out.println(a);
long b = reverse(1256788999);
System.out.println(b);
}
}