Java 实验课:2013/10/24
输入二维矩阵的行和列(row>5,col>5),然后用[0,9]的随机数填充矩阵,检测矩阵中四个方向( 水平,竖直,左斜,右斜)是否存在连续四个相同的数。
package sunquan;
import java.util.*;
class rectangle {
private int row, col;
int[][] rec;
rectangle() {//构造函数:是没有返回值
}
rectangle(int n, int m) {
row = n;col = m;
rec = new int[row][col];
}
public void show() {
for (int i = 0; i < row; i++) {
for (int j = 0; j < col; j++) {
System.out.print(rec[i][j] + " ");
}
System.out.println();
}
}
}
public class Test {
private static int n, m;
private static rectangle r ;
public Boolean solve() {
for (int i = 0; i < n ; i++)
for (int j = 0