Захотелось решить данную задачу через реализацию методов.
В какой-то момент словил себя на мысли что код уж больно грамоздкий.
Может есть идеи по сокращению кода?
package com.javarush.task.task04.task0420;
/*
Сортировка трех чисел
*/
import java.io.*;
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int a = Integer.parseInt(reader.readLine());
int b = Integer.parseInt(reader.readLine());
int c = Integer.parseInt(reader.readLine());
String space = " ";
System.out.println(max(a, b, c) + space + midle(a, b, c) + space + min(a, b, c));
}
public static int min(int a, int b, int c){
if (a <= b && a <= c)
return a;
else if (b <= a && b <= c)
return b;
else
return c;
}
public static int max(int a, int b, int c){
if (a >= b && a >= c)
return a;
else if (b >= a && b >= c)
return b;
else
return c;
}
public static int midle(int a, int b, int c){
int s = a + b + c;
return s - (max(a, b, c) + min(a, b, c));
}
}