if i write SYSO and row++ above the if condition then the result is wrong even when my code is correct
my code:
Scanner s = new Scanner(System.in);
int n = s.nextInt();
// row
int row = 1;
// work
int nst = 1;
int nsp = n / 2;
while (row <= n) {
//space work
int csp = 1;
while (csp <= nsp) {
System.out.print("- ");
csp++;
}
//star work
int cst = 1;
while (cst <= nst) {
System.out.print("* ");
cst++;
}
// preparation
// System.out.println(); if i write this above IF condition result differs
// row++; but my code is correct.
if (row <= n / 2) {
nsp--;
nst = nst + 2;
} else {
nsp++;
nst = nst - 2;
}
System.out.println();
row++;
}