import java.util.Scanner;
class Love
{
public static void main(String[] args)
{
Scanner s=new Scanner(System.in);
while (true)
{
System.out.println("请输入*的最大列数:");
int j=s.nextInt();
love(j);
}
}
public static void love(int j)
{
int i=0;
j=j/4*4;
for (int x=j/4;x<=j/2 ;x++ )
{
for (int y=x;y<j/2 ;y++ )
{
System.out.print(" ");
}
for (int b=0;b<i ;b++ )
{
System.out.print("*");
}
for (int y=i;y<j/2 ;y++ )
{
System.out.print(" ");
}
for (int b=0;b<i ;b++ )
{
System.out.print("*");
}
i+=2;
System.out.println();
}
i=0;
for (int x=0;x<j/2 ;x++ )
{
for (int y=0;y<x;y++ )
{
System.out.print(" ");
}
for (int z=i;z<j ;z++ )
{
System.out.print("*");
}
i+=2;
System.out.println();
}
}
}
学完for循环,自己没事写了一个,技术比较菜,可能程序有很多地方不能处理得很完美. |
|