Here is my code, I am trying to get a specific pattern but I ended up with an unexpected pattern.
for(int i = 0; i < 5; i++)
{
for(int j = 0; j < i * 2; j++)
{
if (i != 3)
{
System.out.print(" ");
}
else
{
System.out.print("*");
}
}
for(int k = 13; k > i * 2; k--)
{
System.out.print("*");
}
System.out.println();
}
I am getting this:
*************
***********
*********
*************
*****
When I should be getting this:
*************
***********
*********
***********
*************
Anyone can help me with this one? Thanks!
Aucun commentaire:
Enregistrer un commentaire