Created
March 30, 2017 12:57
-
-
Save krlakshmikanth/6ce9fa6be18eb7d2c5388a07f8e77749 to your computer and use it in GitHub Desktop.
Sort 3 Integers without using if condition.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
import java.lang.Math; | |
class Main { | |
public static void main(String[] args) | |
{ | |
int a,b,c; | |
Scanner sc = new Scanner(System.in); | |
a=sc.nextInt(); | |
b=sc.nextInt(); | |
c=sc.nextInt(); | |
int big = Math.max(a,Math.max(b,c)); | |
int small = Math.min(a,Math.min(b,c)); | |
int mid = ((a+b+c)-(big+small)); | |
System.out.println(small); | |
System.out.println(mid); | |
System.out.println(big); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment