How to make this pattern if input N = 5 Output :
Mine is like this, it become 2N if input N = 5 Output
Here's my code
int i,j;
for(i = 0; i <= n; i++)
{
for(j = 1; j <= n - i; j++)
System.out.print(" ");
for(j = 1; j <= 2 * i - 1; j++)
System.out.print("*");
System.out.print("\n");
}
for(i = n - 1; i >= 1; i--)
{
for(j = 1; j <= n - i; j++)
System.out.print(" ");
for(j = 1; j <= 2 * i - 1; j++)
System.out.print("*");
System.out.print("\n");
}
What should i fix??
Aucun commentaire:
Enregistrer un commentaire