int z = a;
if(a < b && b < c) z = a;
if(a < c && c < b) z = a;
if(b < c && c < a) z = b;
if(b < a && a < c) z = b;
if(c < a && a < b) z = c;
if(c < b && b < a) z = c;
return z;
en sortie j ai:
1
-3
3
5
tout est juste sauf afficher le plus petit nombre pourtant en sortie ça me paraît juste.
package fr.codegym.task.task02.task0216;
/*
Le plus petit de trois nombres
*/
public class Solution {
public static int min(int a, int b, int c) {
//écris ton code ici
int z = a;
if(a < b && b < c) z = a;
if(a < c && c < b) z = a;
if(b < c && c < a) z = b;
if(b < a && a < c) z = b;
if(c < a && a < b) z = c;
if(c < b && b < a) z = c;
return z;
}
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));
}
}