import javax.swing.JOptionPane;
public class PrintPyramid
{
public static void main(String[] args)
{
String input = JOptionPane.showInputDialog("Enter the number of lines");
int numberOfLines = Integer.parseInt(input);
if (numberOfLines < 1 || numberOfLines > 15)
{
System.out.println("You must input a number 1 ~ 15");
System.exit(0);
}
for (int row = 1; row <= numberOfLines; row++)
{
for (int column = 1; column <= numberOfLines - row; column++)
{
System.out.print(" ");
}
for (int num = row; num >= 1; num--)
{
System.out.print(num >= 10 ? " " + num : " " + num);
}
for (int num = 2; num <= row; num++)
{
System.out.print(num >= 10 ? " " + num : " " + num);
}
for (int num = numberOfLines - row + 1; num >= 1; num--)
{
System.out.print(num >= 10 ? " " + num : " " + num);
}
for (int num = 2; num <= numberOfLines - row + 1; num++)
{
System.out.print(num >= 10 ? " " + num : " " + num);
}
System.out.println();
}
/*
for (int row = numberOfLines - 1; row >= 0; row--)
{
for (int column = 1; column <= numberOfLines - row; column++)
{
System.out.print(" ");
}
for (int num = row; num >= 1; num--)
{
System.out.print(num >= 10 ? " " + num : " " + num);
}
for (int num = 2; num <= row; num++)
{
System.out.print(num >= 10 ? " " + num : " " + num);
}
System.out.println();
}
*/
}
}