Currently you see this:
/:
//::\
///:::\
////::::\\
To fix the spacing, change your first loop as such:
for (int column = 1; column <= 5-row; column++)
{
System.out.print(" ");
}
To get the right amount of colons, notice that we want a function that means the integers to the odd numbers, one function is f(n)=2n+1 and with 1-indexing, we can use f(n)=2n to fix that. You also have no need to print the sides in a loop.
Overall you should get something like this:
public class Main
{
public static void main(String[] args) {
for (int row = 1; row <= 5; row++)
{
for (int column = 1; column <= 5-row; column++)
{
System.out.print(" ");
}
System.out.print("/");
for (int column = 1; column < 2*row; column++)
{
System.out.print(":");
}
System.out.print("\");
System.out.println();
}
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…