package exercise_7;
public class Exercise7_10 {
public static void main(String[] args) {
int[][] test = new int[3][3];
for (int i = 0; i < test.length; i++) {
for (int j = 0; j < test[i].length; j++) {
int t = (int) (Math.random() * 2);
System.out.print(t + " ");
}
System.out.println();
}//自動生成一個3—3的數組
boolean flag=true;
for (int i = 0; i < test.length; i++) {
flag=true;
for (int j = 0; j < test[i].length-1; j++) {//判斷相同行
if (test[i][j]!=test[i][j+1]) {
flag=false;
if (flag) {
System.out.println("All is on row "+i);
break;
}
}
}
for (int j = 0; j < test[i].length-1; j++) {//判斷相同列
if (test[j][i]!=test[j+1][i]) {
flag=false;
if (flag) {
System.out.println("All is on column "+j);
break;
}
}
}
}
}
}
```這是我寫的程序,但是我的程序沒有輸出,我不知道是因為什麼,求告知
for (int i = 0; i < test.length; i++) {
for (int j = 0; j < test[i].length; j++) {
int t = (int) (Math.random() * 2);
test[i][j] = t;//需要給數組賦值
System.out.print(t + " ");
}
System.out.println();
}//自動生成一個3—3的數組