sir i have coded the correct code, the compilation shows no error, even after entering different values i am able to print the corrrect pattern but still it is not showing test cases pass. Can you please tell me why is it??
i am also attacking my code.
//here is my code
import java.util.Scanner;
public class Main
{
public static void main(String args[])
{
Scanner sc= new Scanner(System.in);
int n=sc.nextInt();
sc.close();
int nst=(2*n)+1;
int nsp=1;
int nr=(2*n)+1;
for(int row=1;row<=nr;row++)
{
int val=n;
if(row<=nr/2)
val=(n+1)-row;
else
val=row-(n+1);
//pace
for(int csp=1;csp<=nsp;csp++)
{
System.out.print(" ");
}
for(int cst=1;cst<=nst;cst++)
{
System.out.print(val+" ");
if(cst<=nst/2)
val--;
else
val++;
}
//prep
System.out.println();
if(row<=(nr/2))
{
nst-=2;
nsp++;
}
else
{
nst+=2;
nsp--;
}
}
}
}