对角线增加

时间:2013-09-30 21:24:32

标签: loops increment

        if (shape.equals("diagonal")){
                    for (int row = 0; row <= size; row ++){
                        for (int col = 0 ; col < size; col ++ ){

                            if ( col % 4 == 0 ){
                                System.out.print("*");
                            } else {
                                System.out.print("$");
                            }
                        }
                        System.out.println();
                    }
                }



*$$$*$$$*$$$*$$$*
$*$$$*$$$*$$$*$$$
$$*$$$*$$$*$$$*$$
same as it go down

我的目标是打印上面的代码并继续直到17乘17输出创建

1 个答案:

答案 0 :(得分:1)

尝试替换

if (col % 4 == 0 )

if ( (col+row)%4 == 0 )