package com.codegym.task.task02.task0217;
/*
Minimum of four numbers
*/
public class Solution {
public static int min(int a, int b, int c, int d) {
if (min(a, b) < c) {
return (min(a, b) <= d) ? min(a, b) : d;
} else {
return (c <= d) ? c : d;
}
}
public static int min(int a, int b) {
return (a <= b) ? a : b;
}
public static void main(String[] args) throws Exception {
System.out.println(min(-20, -10));
System.out.println(min(-20, -10, -30, -40));
System.out.println(min(-20, -10, -30, 40));
System.out.println(min(-40, -10, -30, 40));
}
}
ah.bok
Niveau 2
In row 11, what does it mean? and the :
In bespreking
Reacties (1)
- Populair
- Nieuw
- Oud
U moet ingelogd zijn om een reactie achter te laten
Hipo7298
23 July 2024, 15:25
You can see it in the min of two method too.
A brief formula to 'if {} else {} ' when you want to check simply things.
This 2 below is the same:
and
But i don't recommend to use it when your code grow bigger and more difficult, because that confusing, like this row:
... my first thoght was "what the f*ck is this piece of sh*t?"
+1