-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJava BigDecimal.java
43 lines (37 loc) · 944 Bytes
/
Java BigDecimal.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
/* *
* Author: Pavith Bambaravanage
* URL: https://github.com/Pavith19
* */
/*JAVA-15*/
import java.math.BigDecimal;
import java.util.*;
class Solution{
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();
//Write your code here
for (int i = 0; i < n; i++){
for (int j = i; j >= 1; j--){
if (new BigDecimal(s[j]).compareTo(new BigDecimal(s[j-1])) > 0){
String string = s[j];
s[j] = s[j - 1];
s[j-1] = string;
}
else {
break;
}
}
}
//Output
for(int i=0;i<n;i++)
{
System.out.println(s[i]);
}
}
}