for (int i=0;i<3 ;i++ )
{
//打印一个空白的正三角形
for (int j=0 ;j<=i ;j++)
{
System.out.print(" ");
}
//打印一个倒三角形
for (int h=i;h<3 ;h++ )
{
System.out.print("* ");
}
//打印一个正三角形
for (int k=0;k<=i ;k++ )
{
System.out.print("* ");
}
System.out.println();
}
file:///C:/Users/Administrator/AppData/Roaming/Tencent/Users/1060107171/QQ/WinTemp/RichOle/FF050ZZ9%7BDN_35]ZT111R0V.jpg
for (int i=1; i<5;i++ )
{
for (int j=i;j<=4 ;j++ )
{
System.out.print(" ");
}
for (int h=1;h<=i ; h++)
{
System.out.print("* ");
}
System.out.println();
}
[img]file:///C:/Users/Administrator/AppData/Roaming/Tencent/Users/1060107171/QQ/WinTemp/RichOle/DCDLYP60Y7~2UH6ME4W(Z@J.png[/img]
刚学自己做的,请大神门指教有没有更好的……
|
|