Advertisement
Guest User

Sort Three Numbers

a guest
Apr 26th, 2021
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. public static void main(String[] args) {
  2.         Scanner scanner = new Scanner(System.in);
  3.  
  4.         int a = scanner.nextInt();
  5.         int b = scanner.nextInt();
  6.         int c = scanner.nextInt();
  7.  
  8.         if (a==b && b==c){
  9.             System.out.printf("%d %d %d", a,b,c);
  10.         } else {
  11.             sortNums(a, b, c);
  12.         }
  13.     }
  14.     public static void sortNums(int a, int b, int c) {
  15.         if (a >= b && b >= c) {
  16.             System.out.printf("%d %d %d",a,b,c);
  17.         }
  18.         if (b >= a && a >= c) {
  19.             System.out.printf("%d %d %d",b,a,c);
  20.         }
  21.         if (c >= a && a >= b) {
  22.             System.out.printf("%d %d %d",c,a,b);
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement