my code :
Scanner s = new Scanner(System.in);
int n = s.nextInt();
// row
int row = 1;
int nr = 2 * n + 1;
// work
int nsp = 0;
int nst = nr;
// value
int val;
while (row <= nr) {
// value
val = n + 1 - row;
// space work
for (int csp = 1; csp <= nsp; csp++) {
System.out.print("-");
}
// number work
for (int cst = 1; cst <= nst; cst++) {
System.out.print(val);
if (row <= nr / 2 && cst <= nst / 2) {
val--;
} else if (row <= nr / 2 && cst >= nst / 2) {
val++;
} else if (row > nr / 2 && cst <= nst / 2) {
val++;
} else if (row > nr / 2 && cst >= nst / 2) {
val++;
}
}
// preparation
if (row <= nr / 2) {
nsp++;
nst = nst - 2;
} else if (row > nr / 2) {
nsp--;
nst = nst + 2;
}
System.out.println();
row++;
}