import java.util.;
public class Main {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int N=sc.nextInt();
int row=1;
int nsp=2N-1;
int nsd=1;
int ns=1;
while(row<=2N-1){
for(int i=1;i<=nsp;i++){
System.out.print(" ");
}
int m;
if(row<=N) {
m=row;
}
else {
m=2N-row;
}
for(int i=1;i<=nsd;i++){
System.out.print(m+" “);
m–;
}
int j=1;
if(row>1) {
j=2;
}
for(;j<ns;j++){
System.out.print(” “);
}
int k=1;
if(row==1||row==2*N-1) {
k=2;
}
int n=1;
for(;k<=nsd;k++){
System.out.print(n+” ");
n++;
}
System.out.println();
row=row+1;
if(row<=N){
nsp-=2;
nsd++;
ns+=2;
}
else{
nsp+=2;
nsd–;
ns-=2;
}
sc.close();
}
}
}
Test cases failed. But the pattern formed is correct
okk now I got the error.
