All pastes #475398 Raw Edit

Anonymous

public cpp v1 · immutable
·published 2007-05-07 12:39 UTC
rendered paste body
#include<iostream>#include<stdio.h>#include<string.h>#include<stdlib.h>using namespace std;int matrix[100][100],mat[100][100];         int main(){    int n;    char num[10];    int test;    int i,j,k,l;    int len;        len=0;            n=-1;       cin>>n;       for(i=0;i<n;i++) for(j=0;j<n;j++) cin>>matrix[i][j];       len=n;       for(i=0;i<n;i++)       {           for(int j=0;j<n;j++)           {               mat[i][j]=matrix[i][j];               mat[i][j]+=((i==0)?0:mat[i-1][j]);             //  cout<<mat[i][j]<<"  ";           }           //cout<<endl;       }       for(i=0;i<n;i++)       {           for(j=0;j<n;j++)           {               mat[i][j]+=((j==0)?0:mat[i][j-1]);           //    cout<<mat[i][j]<<" ";           }        //   cout<<endl;       }        int ms=matrix[0][0];    for(i=0;i<len;i++)    {        for(j=0;j<len;j++)        {            for(k=i;k<len;k++)            {                for(l=j;l<len;l++)                {                    int s;                    s=mat[k][l]-(i-1<0?0:mat[i-1][l])-(j-1<0?0:mat[k][j-1])+(((i-1)!=-1)&&((j-1)!=-1)?mat[i-1][j-1]:0);                    if(ms<s) ms=s;                }            }        }    }                    cout<<ms<<endl;    }