如何用java写出这个图

来源:百度知道 编辑:UC知道 时间:2024/05/27 02:30:58
*
* * *
* * * * *
* * *
*

class Print{
public static void main(String args[])
{
System.out.println("*\n***\n*****\n***\n*\n");
}
}

int j;
for(int i=0;i<5;i++){
if(i<3)
for(j=0;j<i;j++)
System.out.print("*"+" ");
else
for(;j>0;j--)
System.out.print("*"+" ");
System.our.println();

}