我想打印一个五角星,可是打不出来,前面的代码已经码出来了,求下面接着的代码。
写出来的代码
class Test
{
public static void main(String[] args)
{
WuJiaoXing(5);
}
public static void WuJiaoXing(int s)
{
for (int x = 0;x<s ;x++ )
{
for (int m = 0;m<=s+1 ;m++ )
{
System.out.print(" ");
}
for (int y =x;y<s ;y++ )
{
System.out.print(" ");
}
for (int z = 0;z<x ;z++ )
{
System.out.print("* ");
}
System.out.println();
}
for (int a=0;a<s ;a++ )
{
for (int b = 0;b< 2*s+2 ;b++ )
{
if (b<a)
{
System.out.print(" ");
}
else
{
System.out.print("* ");
}
}
System.out.println();
}
}
}
|
|