-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathBigdecimal.java
More file actions
30 lines (27 loc) · 793 Bytes
/
Bigdecimal.java
File metadata and controls
30 lines (27 loc) · 793 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
import java.math.BigDecimal;
import java.util.*;
public class Bigdecimal{
public static void main(String []args){
//Input
Scanner sc= new Scanner(System.in);
int n=sc.nextInt();
String []s=new String[n+2];
for(int i=0;i<n;i++){
s[i]=sc.next();
}
sc.close();
Arrays.sort(s,0,n, new Comparator<String>(){
@Override
public int compare(String x, String y){
if(x == null || y == null)
return 0x0;
BigDecimal first = new BigDecimal(x), second = new BigDecimal(y);
return second.compareTo(first);
}
});
//Output
for(int i=0;i<n;i++){
System.out.println(s[i]);
}
}
}