空心菱形的打印
class Test4
{
public static void Ju(int a,int b)
{
for(int x=0;x<a;x++)
{
for(int y=0;y<b;y++)
{
System.out.print("*");
}
System.out.println();
}
}
public static void main(String[] args)
{
Ju(4,5);
for (int x=0;x<5 ;x++ )
{
for (int y=x+1;y<5 ;y++ )
{
System.out.print("\u0000");
}
if (x<4)
{
for (int z=0; z<=x; z++)
{
if(z==0||z==x)
System.out.print("*");
else
System.out.print("\u0000");
System.out.print("\u0000");
}
}
if(x<4)
System.out.print("\n");
}
for(int a=0;a<3;a++)
{
for (int b=0;b<a+2 ;b++ )
{
System.out.print("\u0000");
}
if (a<3)
{
for(int c=a+2;c<5;c++)
{
if(c==a+2||c==4)
System.out.print("*");
else
System.out.print("\u0000");
System.out.print("\u0000");
}
}
System.out.print("\n");
}
}
}
|
|