@sinjanspecial:

i think your code is for an 1 D matrix..but i have to find for a 2D matrix..

On Sat, Sep 17, 2011 at 7:33 PM, sinjanspecial <sinjanspec...@gmail.com>wrote:

> hii I think this code will work
>
> #include<stdio.h>
> #include<string.h>
>
> void largestsum(int a[],int n)
> {
>    int s=0,e=0,ls=0,max=0,j,i,sum=0;
>    for(i=0;i<n;i++)
>    {
>        sum+=a[i];
>        if(sum>max)
>        {
>            max=sum;
>            e=i;
>            s=ls;
>        }
>        if(sum<0)
>        {
>            sum=0;
>            ls=i+1;
>        }
>    }
>    printf("\nlargest sum is=%d\n",max);
>    printf("The element which make largest sum is\t");
>    for(j=s;j<=e;j++)
>    {
>        printf("%d\t",a[j]);
>    }
> }
>
> int main() {
>
>    int a[]={6,4,-5,5,2,8,-21,15,4};
>    int n=9;
>    largestsum(a,n);
>
>
>    return 0;
> }
>
> Thanks & Regards
> Sinjan
> M.Tech(s/w engg)
> DTU delhi
> On Sep 17, 2:55 pm, prasanth n <nprasnt...@gmail.com> wrote:
> > given a matrix with +ve and -ve numbers, find the submatrix with maximum
> > sum??
> >
> > --
> > *prasanth*
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>


-- 
*prasanth*

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to