2013-09-30 29 views
-2
 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

更換

if (col % 4 == 0) 

目前尚不清楚在所有你問的問題 – bengoesboom

回答

1

嘗試用

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

非常感謝你 – Lee