Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package src;
- import java.util.Scanner;
- public class SortNumbers {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int first = Integer.parseInt(scanner.nextLine());
- int second = Integer.parseInt(scanner.nextLine());
- int third = Integer.parseInt(scanner.nextLine());
- int number = Math.max(Math.max(first, second), third);
- if (number == third) {
- System.out.println(third);
- System.out.println(Math.max(first, second));
- System.out.println(Math.min(first, second));
- } else if (number == second) {
- System.out.println(second);
- System.out.println(Math.max(first, third));
- System.out.println(Math.min(first, third));
- } else {
- System.out.println(first);
- System.out.println(Math.max(second, third));
- System.out.println(Math.min(second, third));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment