package com.codegym.task.task04.task0420;
/*
Sorting three numbers
*/
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws Exception {
Scanner scanner = new Scanner(System.in);
int a = Integer.parseInt(scanner.nextLine());
int b = Integer.parseInt(scanner.nextLine());
int c = Integer.parseInt(scanner.nextLine());
int min = 0;
int med = 0;
int max = 0;
if ( a <= b && a <= c ){
min = a;
if (b <= c){
med = b;
max = c;
}
else {
med = c;
max = b;
}
System.out.println(max + " " + med + " " + min);
}
else if (b <= a && b <= c){
min = b;
if (a <= c){
med = a;
max = c;
}
else {
med = c;
max = a;
}
System.out.println(max + " " + med + " " + min);
}
else {
min = c;
if (a <= b){
med = a;
max = b;
}
else {
med = b;
max = a;
}
System.out.println(max + " " + med + " " + min);
}
}
}
Got this to work but this code seems to be to long, any shorter way of doing it?
Resolved
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Guadalupe Gagnon
18 February 2020, 14:35
yes, but why waste time on this when you will learn new techniques if you continue?
0
Timothy Strickland DevOps at Boeing
19 February 2020, 00:03
Good point
0