Didart

Sort Numbers

Sep 21st, 2021
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. package src;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class SortNumbers {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int first = Integer.parseInt(scanner.nextLine());
  10.         int second = Integer.parseInt(scanner.nextLine());
  11.         int third = Integer.parseInt(scanner.nextLine());
  12.  
  13.         int number = Math.max(Math.max(first, second), third);
  14.         if (number == third) {
  15.             System.out.println(third);
  16.             System.out.println(Math.max(first,  second));
  17.             System.out.println(Math.min(first, second));
  18.         } else if (number == second) {
  19.             System.out.println(second);
  20.             System.out.println(Math.max(first, third));
  21.             System.out.println(Math.min(first, third));
  22.         } else {
  23.             System.out.println(first);
  24.             System.out.println(Math.max(second, third));
  25.             System.out.println(Math.min(second, third));
  26.         }
  27.     }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment