Advertisement
Hey_Donny

Sort Three Numbers

Mar 6th, 2022
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. public static boolean rangeCheck (int num, int min, int max){
  5. return num > min && num < max;
  6. }
  7. public static void main(String[] args) {
  8. Scanner scanner = new Scanner(System.in);
  9.  
  10. int a = scanner.nextInt();
  11. int b = scanner.nextInt();
  12. int c = scanner.nextInt();
  13. if (rangeCheck(c, -1000, 1000))
  14. if ((a > b) && (a > c)) {
  15. if (b > c) {
  16. System.out.printf("%d %d %d", a, b, c);
  17. } else
  18. System.out.printf("%d %d %d", a, c, b);
  19. } else if ((b > a) && (b > c)) {
  20. if (a > c) {
  21. System.out.printf("%d %d %d", b, a, c);
  22. } else
  23. System.out.printf("%d %d %d", b, c, a);
  24. } else if ((c > a) && (c > b)) {
  25. if (a > b) {
  26. System.out.printf("%d %d %d", c, a, b);
  27. } else
  28. System.out.printf("%d %d %d", c, b, a);
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement