#include<iostream.h> typedef struct Element { int index; int sum; }Element; void main() { int array[]={-33,16,-48,5,16,-2,3,-11,10,-1}; Element elem; elem.index=0; elem.sum=array[0]; int temp=array[0]; for(int i=1;i<sizeof(array)/sizeof(int);i++) { if(temp<0) temp=0; temp+=array[i]; if(temp>elem.sum) { elem.index=i;elem.sum=temp; } } cout<<elem.index<<" "<<elem.sum<<endl; }