class For
{
public static void main(String[] args)
{
for (int x = 1;x<6 ; x++)
{
for (int y = x;y<6 ;y++ ) //为左边的倒三角占一个位置,防止#形成三角形从最左边开始
{
System.out.print(" ");
}
for (int y = 1;y<=2*x-1 ;y++ )//形成一个正三角形
{
System.out.print("#");
}
System.out.println();
}
for (int x = 1;x<5 ; x++)
{
for (int y = 1;y<=x+1 ;y++ )
{
System.out.print(" ");
}
for (int y = 1;y<=2*(4-x)+1 ;y++ )
{
System.out.print("#");
}
System.out.println();
}
}
} |
|