我需要的是改变我的第一个声明,为八边形的下半部分留出空间。
public class Octo {
public static void draw(int len, String c) {
for (int num = 1; num <= len; num++) {
System.out.print(c);
}
}
public static void Octogon(int length){
draw(length-1, " ");
draw(length, "*");
draw(length-1, " ");
System.out.println();
for(int row =1 ;row < length ; row++) {
draw(length -row -1, " ");
draw(1, "*");
draw(length+2 *row -2 , " ");
draw(1, "*");
System.out.println();
}
for(int row2 = 1 ; row2 < 3 ; row2++) {
System.out.println("* *");
}
}
}