-
Notifications
You must be signed in to change notification settings - Fork 0
/
J02031.java
39 lines (38 loc) · 1.06 KB
/
J02031.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
34
35
36
37
38
39
import java.util.*;
public abstract class J02031 {
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;
Stack<String> mys = new Stack<String>();
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)+": ");
String s = "";
for(int h = 0;h<n;h++){
s += Integer.toString(a[h]);
s += " ";
}
mys.push(s);
}
for (int i = n-1;i>=1;i--){
System.out.print("Buoc "+i+": ");
System.out.println(mys.peek());
mys.pop();
}
}
}