Ребят где ошибка? Выдает 2 раза ответ, при вводе "123"
Вывод:
3 2 1
3 1 1
package com.javarush.task.task04.task0420;
/*
Сортировка трех чисел
*/
import java.awt.event.MouseAdapter;
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) throws Exception {
Scanner scanner = new Scanner(System.in);
int a = scanner.nextInt();// 8
int b = scanner.nextInt();//12
int c = scanner.nextInt();//1
int max = Math.max(a, b);//b
int min;//c
int cred;
if (max < c) { //Для максим C
max = c;
if (a < b) {
min = a;
cred = b;
System.out.println(max + " " + cred + " " + min);
} else
min = b;
cred = a;
System.out.println(max + " " + cred + " " + min);
}else {
if (max > c && max > a) { //Для максим B
min = Math.min(a, c);
if (min < c) {
cred = c;
System.out.println(max + " " + cred + " " + min);
} else {
cred = a;
System.out.println(max + " " + cred + " " + min);
}
}else {
if (max>c&&max>b){ // Для Макс A
min = Math.min(b,c);
if(min<c){
cred = c;
System.out.println(max + " " + cred + " " + min);
}else {
cred= a;
System.out.println(max + " " + cred + " " + min);
}
}
}
}
}
}