Pattern20 of pattern pdf (Its not working )

Scanner sc = new Scanner(System.in);

	int n = sc.nextInt();

	int row = 1;

	int nst = 1;
	int nsp = n / 2;

	while (row <= n) {
		// spaces
		for (int csp = 1; csp <= nsp; csp++) {

			System.out.print("  ");
		}
		// stars
		for (int cst = 1; cst <= nst; cst++) {
			if (cst == 1 || cst == nst)
				System.out.print("* ");

			else
				System.out.print(" ");

		}
		//update
		System.out.println();
		if (row <= n / 2) {
			nsp--;
		} else {
			nsp++;
		}

		if (row <= n / 2) {
			nst = nst + 2;
		} else {
			nst = nst - 2;
		}
		row++;

	}