using namespace std;
int main()
{
int N, m, n, k, sum, max;
int arr[10][10];
cin >> N;
for (int i = 0; i < N; i++)
{
sum = 0;
max = 0;
cin >> m >> n >> k;
for (int x = 0; x < m; x++)
for (int y = 0; y < n; y++)
cin >> arr[x][y];
if (k >= 2)
{
for (int x = 0; x <= m - k; x++)
{
for (int y = 0; y <= n - k; y++)
{
sum = 0;
for (int j = x; j < x + k; j++)
for (int g = y; g < y + k; g++)
sum += arr[j][g];
if (sum > max)
max = sum;
}
}
}
else
{
for (int x = 0; x < m; x++)
{
for (int y = 0; y < n; y++)
{
if (arr[x][y] > max)
max = arr[x][y];
}
}
}
cout << max << endl;
}
return 0;
}
沒有留言:
張貼留言