阅读背景:

钻石形状Java用于循环

来源:互联网 

Here is my code:

这是我的代码:

public static void drawNumDiamond(int h) {


    char c= 'A';
    if(h!=0) {
        if (h % 2 == 1) {


            for (int i = h/2; i >= -(h/2); i--) {

                for (int j = 1; j <= Math.abs(i); j++) {
                    System.out.print("-");
                }
                for (int j = 0; j <= 2 * ((h/2) - Math.abs(i)); j++) {
                    System.out.print(c);
                }

                System.out.println();
                if (i > 0) {
                    c++;
                } else {
                    c--;
                }
            }
        } else {
            System.out.println("NO VALID INPUT");
        }
    }

}
public static voi



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: