Help me out to adjust spaces

code:-
import java.util.;
public class Main {
public static void main(String args[]) {
int n ;
Scanner sc = new Scanner(System.in);
n=sc.nextInt();
int row=1;
int nst;
int nsp=2
n-3;
while(row<=n){
nst=row;
for(int cst = 1;cst<=nst;cst++){
System.out.print(cst);
for(int i=0 ; i<n;i++)
System.out.print(" “);
}
for(int csp=1;csp<=nsp;csp++){
System.out.print(” “);
}
for(int cs =nst;cs>0;cs–){
if(cs==n){
cs=n-1;}
System.out.print(cs);
for(int j=0 ; j<n;j++)
System.out.print(” “);
}
nsp=nsp-2;
row=row+1;
System.out.println(”\n");
}
}
}

Hi Ishant

I have made the required changes to your code. It should work fine now.

import java.util.*;

public class Main {
public static void main(String args[]) {
int n;
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
int row = 1;
int nst ;
int nsp = 2 * n - 3;
while (row <= n) {
nst = row;
for (int cst = 1; cst <= nst; cst++) {
System.out.print(cst + " “);
}
for (int csp = 1; csp <= nsp; csp++) {
System.out.print(” " + " ");
}
for (int cs = nst; cs > 0; cs–) {
if (cs == n) {
cs = n - 1;
}
System.out.print(cs + " ");

		}
		nsp = nsp - 2;
		row = row + 1;
		System.out.println();
	}
}

}

Hi @Ishant
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.