You are viewing a single comment's thread. Return to all comments →
Solution w/o List, Collections;
Scanner sc= new Scanner(System.in); int n=sc.nextInt(); String []s=new String[n]; for(int i=0;i<n;i++){ s[i]=sc.next(); } for(int i=0; i<n-1; i++){ for(int j=0; j<n-i-1; j++){ BigDecimal a = new BigDecimal(s[j]); BigDecimal b = new BigDecimal(s[j+1]); if (a.compareTo(b) == -1){ String temp = s[j]; s[j] = s[j + 1]; s[j + 1] = temp; } } } for(int i=0;i<n;i++){ System.out.println(s[i]); }
Seems like cookies are disabled on this browser, please enable them to open this website
Java BigDecimal
You are viewing a single comment's thread. Return to all comments →
Solution w/o List, Collections;