2016-11-17 36 views
-3

我正在嘗試爲我的膝蓋創建checkcerboard,並且遇到了我的代碼問題。如何使用java創建CheckerBoard

int rr = 18; 
int cc = 16; 
for (int j= 0; j<=cc; j++) { 
    for(int i = 0; i<=rr; i++){ 
     if(i % 2 == 0){ 
      System.out.print(design); 

     } 
     System.out.print(design); 
    } 
    System.out.println(); 
} 
+5

所以有什麼問題你面對? –

回答

1

我做了這樣的:

public static void main(String[] args) { 

     int rows = 8; 
     int columns = 8; 
     String sign = "*"; 

     for(int i = 0; i < rows; i++) { 
      for (int j = 0; j < columns; j++) { 
       System.out.print(sign); 
      } 
      System.out.println(); 
     } 

    }