-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1-Reverse-the-Num.java
More file actions
57 lines (46 loc) · 860 Bytes
/
1-Reverse-the-Num.java
File metadata and controls
57 lines (46 loc) · 860 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Question
/*Given an Integer N, write a program to reverse it.
Input
The first line contains an integer T, total number of testcases. Then follow T lines, each line contains an integer N.
Output
For each test case, display the reverse of the given number N, in a new line.
Constraints
1 ≤ T ≤ 1000
1 ≤ N ≤ 1000000
Example
Input
4
12345
31203
2123
2300
Output
54321
30213
3212
32 */
//Solution
import java.util.*;
import java.lang.*;
import java.io.*;
class Sol
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner scan=new Scanner(System.in);
int test=scan.nextInt();
for(int i=0; i<test; i++){
try{
long num=scan.nextLong();
long rev=0;
while(num!=0){
long rem=num%10;
rev=rev*10+rem;
num=num/10;
}
System.out.println(rev);
}
catch(Exception e){return;}
}
}
}