"IF ELSE - ELSE IF STATEMENT"
Input
A line containing three integers is separated by a space.
6 1 3
Output
A line containing three integers is separated by a space.
1 3 6
import java.util.Scanner;
public class App {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a = in.nextInt();
int b = in.nextInt();
int c = in.nextInt();
if (a < b && a < c && b < c) {
System.out.printf("%d %d %d", a, b, c);
} else if (b < c && b < a && c < a) {
System.out.printf("%d %d %d", b, c, a);
} else if (c < a && c < b) {
System.out.printf("%d %d %d", c, b, a);
} else {
System.out.printf("%d %d %d", a, c, b);
}
in.close();
}
}
Comments
Leave a comment