/*
目标打印一个空心的菱形
空几行以后打印第一个三角的顶点
然后倒着打三角
*/
class Kong
{
public static void main(String[] args)
{
int sum=4;
int small=1;
int max=9;
for(int x=1;x<6;x++)
{
for (int z=sum;z>0;z-- )
{
System.out.print(" ");
}
for(int y=0;y<small;y++)
{
if ((y==0)|(y==small-1))
{
System.out.print("*");
}
else
System.out.print(" ");
}
sum--;
max=max-2;
small=small+2;
System.out.println();
}
int sum1=9;
for (int a=0;a<6 ;a++ )
{
for (int c=a;c>0 ;c-- )
{
System.out.print(" ");
}
for (int b=sum1;b>1 ;b-- )
{
if ((b==2)|(b==sum1-1))
{
System.out.print("*");
}
else
System.out.print(" ");
}
sum1=sum1-2;
System.out.println();
}
}
}
|
|