Минимум 4х чисел. посмотрите пожалуйста код.
package com.javarush.task.task02.task0217;
/*
Минимум четырех чисел
*/
public class Solution {
public static int min(int a, int b, int c, int d) {
int s = min(a,b);
int x;
if (s < c){
x = s;
if (c < d)
x = d;
}
else {
x = c;
if (c < s)
x = c;
}
return x;
}
public static int min(int a, int b) {
if (a < b)
return a;
else
return 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));
}
}