forked from alokya998/Redux-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregistration.java
More file actions
49 lines (49 loc) · 996 Bytes
/
registration.java
File metadata and controls
49 lines (49 loc) · 996 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
package dados31;
import java.util.Scanner;
public class Dados31 {
public static void main(String[] args) {
final int QUANT = 10;
int [] v = new int[QUANT];
Scanner entrada = new Scanner(System.in);
String s;
int n = -1;
char tecla;
do {
n++;
System.out.print("Valor: ");
v[n] = Integer.parseInt(s);
} while (v[n] != 0 && n < QUANT);
if (v[n] == 0) {
n--;
}
sortForcaBruta(v, n);
exibeLista(v, n);
System.exit(0);
}
// ------------------------------------------------------- sortForcaBruta
static void sortForcaBruta(int [] v, int n) {
for (int i = 0;i < n;i++) {
for (int j = i+1;j <= n;j++) {
if (v[i] > v[j]) {
int temp = v[i];
v[i] = v[j];
v[j] = temp;
}
}
}
}
// ------------------------------------------------------- exibe
static void exibeLista(int [] v, int n) {
System.out.print("Lista: ");
if (n == -1) {
System.out.println("Vazia");
}
else {
for (int i = 0;i <= n;i++) {
System.out.printf("%2d ", v[i]);
}
}
System.out.println();
}
}