i did not understand how to correct the 1st and last row in this pattern.
my code:
Scanner s = new Scanner(System.in);
int n = s.nextInt();
// row
int row = 1;
// work
int nsp = -1;
int nst = n/2;
while (row <= n) {
//work stars
for (int cst = 1; cst <= nst; cst++) {
System.out.print("* ");
}
// work spaces
for (int csp = 1; csp <= nsp; csp++) {
System.out.print("- ");
}
//work stars
for (int cst = 1; cst <= nst; cst++) {
System.out.print("* ");
}
// preparation
if (row <= n / 2) {
nst--;
nsp = nsp + 2;
} else {
nst++;
nsp = nsp - 2;
}
System.out.println();
row++;
}