-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJ02013
30 lines (28 loc) · 836 Bytes
/
J02013
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
package test;
import java.util.Scanner;
public class J02013 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int a[] = new int[n];
for (int i = 0; i < n; i++)
a[i] = sc.nextInt();
for (int i = n - 1; i >= 0; i--) {
int s = 0;
for (int j = 0; j < i; j++) {
if (a[j + 1] < a[j]) {
int k = a[j + 1];
a[j + 1] = a[j];
a[j] = k;
} else
s++;
}
if (s == i)
return;
System.out.printf("Buoc %d: ", n - i);
for (int j = 0; j < n; j++)
System.out.printf("%d ", a[j]);
System.out.println();
}
}
}