Wiem, że można to zrobić dużo krócej, ale na razie tylko taki sposob znam :) . Chyba gdzieś jest błąd w konstrukcji, ale nie mogę go znaleźć.
package pl.codegym.task.task02.task0216;
/*
Najmniejsza z trzech liczb
*/
public class Solution {
public static int min(int a, int b, int c) {
//tutaj wpisz swój kod
if (a < b) {
if (a < c) {
return a;
}
else {
return c;
}
}
else {
if (b < a) {
if (b < c) {
return b;
}
else (c < b) {
return c;
}
}
}
public static void main(String[] args) throws Exception {
System.out.println(min(1, 2, 3));
System.out.println(min(-1, -2, -3));
System.out.println(min(3, 5, 3));
System.out.println(min(5, 5, 10));
}
}