-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlip2908.java
More file actions
36 lines (32 loc) · 856 Bytes
/
Flip2908.java
File metadata and controls
36 lines (32 loc) · 856 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
import java.io.IOException;
import java.util.Scanner;
public class Flip2908 {
public static int a, b;
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
a = sc.nextInt();
b = sc.nextInt();
compareNum(a, b);
}
public static void compareNum(int a, int b) {
do {
if (a % 10 > b % 10) {
printReverse(a);
break;
} else if (a % 10 < b % 10) {
printReverse(b);
break;
} else {
System.out.print(a % 10);
}
a /= 10;
b /= 10;
} while (a != 0);
}
public static void printReverse(int a) {
do {
System.out.print(a % 10);
a /= 10;
} while (a != 0);
}
}