Last active
August 7, 2020 11:42
-
-
Save resovarish/956e0f96e69dd93e256ce03f4afcb202 to your computer and use it in GitHub Desktop.
Function that returns the minimum of 4 numbers // Функция, вычисляющая минимум из 4 чисел // Написать функцию, которая вычисляет минимум из четырёх чисел
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int min4(int a, int b, int c, int d) { | |
int g = min2(a, b); | |
int f; | |
if (g < c) { | |
if (g < d) | |
f = g; | |
else | |
f = d; | |
} else { | |
if (c < d) | |
f = c; | |
else | |
f = d; | |
} | |
return f; | |
} | |
public static int min2(int a, int b) { | |
int d; | |
if (a < b) | |
d = a; | |
else | |
d = b; | |
return d; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment