Advertisement
dentia

Three Largest Numbers

Jun 17th, 2014
210
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package _27ExamPreparation;
  2.  
  3. import java.math.BigDecimal;
  4. import java.util.Arrays;
  5. import java.util.Locale;
  6. import java.util.Scanner;
  7.  
  8. public class _02task {
  9.     public static void main(String[] args) {
  10.         Locale.setDefault(Locale.ROOT);
  11.        
  12.         Scanner in = new Scanner(System.in);
  13.         int n = Integer.parseInt(in.nextLine());
  14.        
  15.         BigDecimal[] numbers = new BigDecimal[n];
  16.         for (int i = 0; i < numbers.length; i++) {
  17.             numbers[i] = new BigDecimal(in.nextLine());
  18.         }
  19.        
  20.         Arrays.sort(numbers);
  21.        
  22.        
  23.         for (int i = numbers.length-1, count = 3; i >= 0 && count >0; i--, count--) {
  24.             System.out.println(numbers[i].toPlainString());
  25.         }
  26.     }
  27. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement