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);
test[i][j]=t;
System.out.print(test[i][j]+ " ");
}
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;
}
}
}
}
}
}