Difference between r1.3 and the current
@@ -58,3 +58,5 @@
== 잡담 ==
* 더블 포인터 안 쓰고 하려고 했는데 머리가 딸려서 -_-;;;;
----
[ACM_ICPC/2011년스터디]
소스 ¶
#include <iostream> #include <malloc.h> using namespace std; int main() { int getRow = 0; int getCol = 0; int greatestNum = 0; int currentRow = 0; int currentCol = 0; int **lawn; int temp = 0; cin >> getRow >> getCol; while((getRow < 3) || (getCol < 3)) cin >> getRow >> getCol; lawn = (int**)malloc(sizeof(int) * getRow); for(int i = 0; i < getRow; i++) *(lawn + i) = (int*)malloc(sizeof(int) * getCol); for(int i = 0; i < getRow; i++) { for(int j = 0; j < getCol; j++) cin >> lawn[i][j]; } for(int i = 0; i < (getRow - 2);i++) { for(int j = 0; j < (getCol - 2); j++) { temp = lawn[i][j] + lawn[i][j + 1] + lawn[i][j + 2] + lawn[i + 1][j] + lawn[i + 1][j + 1] + lawn[i + 1][j + 2] + lawn[i + 2][j] + lawn[i + 2][j + 1] + lawn[i + 2][j + 2]; if(temp > greatestNum) { greatestNum = temp; currentRow = i + 1; currentCol = j + 1; } } } cout << greatestNum << endl << currentRow << " " << currentCol << endl; free(lawn); return 0; }