[转]http://blog.csdn.net/zxy_snow/article/details/5998184
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#define N 101
using namespace std;
int Maxsum(int n, int *a)
{
int sum = 0,b = 0;
for(int i=0; i<n; i++)
{
if( b > 0 )
b += a[i];
else
b = a[i];
if( b > sum )
sum = b;
}
return sum;
}
int main(void)
{
int n,mat[N][N];
int sum[N],max = 0;
cin >> n;
for(int i=0; i<n; i++)
for(int k=0; k<n; k++)
cin >> mat[i][k];
for(int i=0; i<n; i++)
{
memset(sum,0,sizeof(sum));
for(int k=i; k<n; k++)
{
for(int j=0; j<n; j++)
sum[j] += mat[k][j];
int tempsum = Maxsum(n,sum);
if( tempsum > max )
max = tempsum;
}
}
cout << max << endl;
return 0;
}
分享到:
相关推荐
学习ACM程序设计的朋友一定要看,这是训练必备的POJ ZOJ题目分类及解题思路
Interview,ZOJ,POJ 等平台。 欢迎Coders对代码加以指正和提议! 常见问题总结 两整数求平均值 average = min + (max - min) / 2 防止两整数的和越界 整数乘积对比 1.0 * m * m == num 类似乘积对比, 需转为double...
自动探测POJ、HDU、SOJ、ZOJ水题,对于有志于刷遍各种水题的ACMer来说非常有用
zoj吐血制作,希望大家喜欢
利用vjudge源码改造爬虫抓取vjudge全局共享答案资源。 ACMer,请用于参考思路,对拍代码,不要直接提交。
ZOJ解题报告ZOJ解题报告ZOJ解题报告ZOJ解题报告
zoj题目简单归类zoj题目简单归类zoj题目简单归类
acm中zoj1002的可运行C++程序
包含了zoj700多道题目的源代码,在做题时可以参考
To prevent other companies from revealing his secret, he decided to use a substitution cipher in all the letters mentioning the new play. Substitution cipher is defined by a substitution table ...
Problem Arrangement zoj 3777
ZOJ题目答案源码
zoj 1255 The Path.md
zoj 1610 Count the Colors.md
一个非常非常非常非常实用的zoj结题代码
zoj 1810 The Gourmet Club.md
zoj 2499 The Happy Worm.md
zoj 2151 The Highest Profits.md
It costs R yuans for the theatre to run each show, and S yuans to serve each of the audiences during each show. Now your job is to write a program to maximize the total revenue of each show for the ...
zoj 1566 Too Lazy To Move.md