Получается, в моем коде все числа сравниваются кучу раз. В результате выходит "7 5 4", что является правильным ответом. Так же, хотелось бы узнать более лаконичный способ записи данного кода. Заранее спасибо
package com.javarush.task.task04.task0420;
/*
Сортировка трех чисел
*/
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int a,b,c;
a=sc.nextInt();
b=sc.nextInt();
c=sc.nextInt();
if (a>b && a>c)
System.out.print(a+" ");
else if (b>a && b>c)
System.out.print(b+" ");
else if (c>a && c>b)
System.out.print(c+" ");
//первая цифра определена.
if ((a<b && a>c) || (a<c && a>b))
System.out.print(a+" ");
else if ((b<a && b>c) || (b<c && b>a))
System.out.print(b+" ");
else if ((c<a && c>b) || (c<b && c>a))
System.out.print(c+" ");
//вторая цифра определена.
if (a<b && a<c)
System.out.print(a);
else if (b<a && b<c)
System.out.print(b);
else if (c<a && c<b)
System.out.print(c);
}
}