Pattern 18 problem with system out and row++

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++;
	}

Hi nipun,it gives different result because when you do row++ above the if condition then in the if condition not that current row is compared with n/2 but the next row due to row++,hence the result differs.

Hi Nipun,
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.

Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.

i mark problem resolved but when i login again it starts showing in the unresolved section.