private int getMaxValue_2(int[][] inputData, int endValue) {
int maximumValue = 0; // rtn 값
int inputSize = inputData.length; // 배열 size
int cur_x_st = 0;
int cur_x_end = endValue;
int cur_y_st = 0;
int cur_y_end = endValue;
int tmp_max = 0; // ? Integer.MIN_VALUE;
while (cur_x_end <= inputSize) { // N x N 배열의 사이즈를 넘지 않아야 ...
tmp_max = 0;
for (int i=cur_x_st; i< cur_x_end ; i++) {
for (int j=cur_y_st; j< cur_y_end ; j++) {
tmp_max += inputData[i][j];
}
}
cur_y_st++;
cur_y_end++; // 일단 열이 증가하도록
if (cur_y_end > inputSize) { // 열이 증가하다가 배열의 사이즈 보더 커지면
cur_x_st++;
cur_x_end++;
cur_y_st = 0;
cur_y_end = endValue;
}
if (maximumValue < tmp_max) {
maximumValue = tmp_max;
}
}
return maximumValue;
}
Aggregate
2019. 8. 30. 11:28