-
Notifications
You must be signed in to change notification settings - Fork 0
/
Direct_Echange.java
33 lines (33 loc) · 945 Bytes
/
Direct_Echange.java
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 Direct_Echange {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int a[] = new int[10001];
for(int i=0;i<n;i++){
a[i] = in.nextInt();
}
int k = 1;
for(int i=0;i<n-1;i++){
boolean ok = true;
int x = i;
for(int j=i+1;j<n;j++){
if(a[j] < a[x]){
x = j;
ok = false;
}
}
if(!ok){
int t = a[x];
a[x] = a[i];
a[i] = t;
System.out.print("Buoc "+ k + ": ");
k++;
// System.out.println(Arrays.toString(a));
for(int h = 0;h<n;h++)
System.out.print(a[h] + " ");
}
System.out.println();
}
}
}