该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include
#include
int main()
{
int i, j, h, k, n, max, sum, cur, matrix[101][101];
while (scanf("%d", &n) != EOF)
{
for (i = 0; i < n; i ++)
{
for (j = 0; j < n; j ++)
scanf("%d", *(matrix + i) + j);
}
max = matrix[0][0];
for (i = 0; i < n; i ++)
{
for (j = i; j < n; j ++)
{
for (k = i, sum = 0; k <= j; k ++)
sum += matrix[k][0];
if (sum > max)
max = sum;
for (h = 1; h < n; h ++)
{
for (k = i, cur = 0; k <= j; k ++)
cur += matrix[k][h];
if (sum >= 0)
sum += cur;
else
sum = cur;
if (sum > max) max = sum;
}
}
}
printf("%d\n", max);
}
return 0;
}