/*
打印一等腰三角形
*/
class Demo
{
public static void main(String [] args)
{
for (int x=1; x<=5; x++)//外层for循环控制打印行数
{
for (int y=x; y<=4; y++)//改变初始化表达式,打印尖朝下
{
System.out.print(" ");
}
for (int z=1; z<=x; z++)//改变循环条件尖朝上
{
System.out.print("* ");
}
System.out.println();
}
}
} |
|