-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlgFour.java
More file actions
30 lines (23 loc) · 792 Bytes
/
AlgFour.java
File metadata and controls
30 lines (23 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import java.util.Scanner;
public class AlgFour {
public static void main(String[] args) {
int[] numeros = new int[3];
Scanner leitor = new Scanner(System.in);
for(int i = 0; i < 3; i++) {
System.out.println("Informe o número: ");
numeros[i] = leitor.nextInt();
}
for(int j = 0; j < numeros.length - 1; j++) {
for(int k = 0; k < numeros.length - j - 1; k++) {
if(numeros[k] > numeros[k + 1]) {
int temp = numeros[k];
numeros[k] = numeros[k + 1];
numeros[k + 1] = temp;
}
}
}
for(int numero : numeros) {
System.out.println(numero);
}
}
}