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;
}

'프로그래밍언어' 카테고리의 다른 글

시저 암호  (0) 2019.08.30
소수 찾기  (0) 2019.08.30
문자열 내 마음대로 정렬하기  (0) 2019.08.30
K번째수  (0) 2019.08.30
체육복  (0) 2019.08.30

+ Recent posts