/**
* 输出:
* *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* *
*/
public class exercise4_6_4
{
public static void main(String[] args)
{
for(int a=4,b=1;a+b<=9;a--,b+=2)
{
for(int c=1;c<=a;c++)
System.out.print(" ");
for(int d=1;d<=b;d++)
{
if(d==1||d==b)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
for(int a=1,b=7;a+b>=5;a++,b-=2)
{
for(int c=1;c<=a;c++)
System.out.print(" ");
for(int d=1;d<=b;d++)
{
if(d==1||d==b)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
* 输出:
* *
* * *
* * *
* * *
* * *
* * *
* * *
* * *
* *
*/
public class exercise4_6_4
{
public static void main(String[] args)
{
for(int a=4,b=1;a+b<=9;a--,b+=2)
{
for(int c=1;c<=a;c++)
System.out.print(" ");
for(int d=1;d<=b;d++)
{
if(d==1||d==b)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
for(int a=1,b=7;a+b>=5;a++,b-=2)
{
for(int c=1;c<=a;c++)
System.out.print(" ");
for(int d=1;d<=b;d++)
{
if(d==1||d==b)
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
}
}
回复Comments
作者:
{commentrecontent}