Created
December 1, 2014 22:56
-
-
Save JRGGRoberto/00c837732d7a0ead5492 to your computer and use it in GitHub Desktop.
Ordena 3 números
This file contains hidden or 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; | |
public class ordena { | |
public static void main(String[] args) { | |
int[] num = new int[3]; | |
Scanner key = new Scanner(System.in); | |
System.out.print("N1:"); | |
num[0] = key.nextInt(); | |
System.out.print("N2:"); | |
num[1] = key.nextInt(); | |
System.out.print("N3:"); | |
num[2] = key.nextInt(); | |
key.close(); | |
int aux; | |
if (num[0] > num[1]){ | |
aux = num[0]; | |
num[0] = num[1]; | |
num[1] = aux; | |
} | |
if (num[1] > num[2]){ | |
aux = num[1]; | |
num[1] = num[2]; | |
num[2] = aux; | |
} | |
if (num[0] > num[1]){ | |
aux = num[0]; | |
num[0] = num[1]; | |
num[1] = aux; | |
} | |
System.out.println(num[0] +", "+ num[1] +", "+ num[2]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment