-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSort_Select.java
More file actions
33 lines (29 loc) · 850 Bytes
/
Sort_Select.java
File metadata and controls
33 lines (29 loc) · 850 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
import java.util.*;
public abstract class Sort_Select {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int a[] = new int[n];
for(int i=0;i<n;i++){
a[i] = in.nextInt();
}
int k = 1,min = 0;
for(int i=0;i<n-1;i++){
min = i;
boolean ok = true;
for(int j=i+1;j<n;j++){
if(a[j] < a[min]){
min = j;
ok = false;
}
}
int t = a[i];
a[i] = a[min];
a[min] = t;
System.out.print("Buoc "+(i+1)+": ");
for(int h = 0;h<n;h++)
System.out.print(a[h]+" ");
System.out.println();
}
}
}