我建议您这样做:
int perTotal = 0;// top and bottom rowfor (int c = 0; c < numCols; c++) perTotal += matrix[0][c] + matrix[numRows-1][c];// left and right columnfor (int r = 1; r < numRows-1; r++) perTotal += matrix[r][0] + matrix[r][numCols-1];// outputSystem.out.println("Perimeter=" + perTotal);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)