#include
using namespace std;
int main() {
int arr[]={-2,3,1,6,8,0,-5,-7};
int n= sizeof(arr)/sizeof(arr[0]);
/* int su[n];
int sum=0;
for(int i=0;i<n;i++){
sum+=arr[i];
su[i]=sum;
}
for(int i=0;i<n;i++){
cout<<su[i]<<" ";
}
*/
int l=-1,r=-1;
int csum =0,fsum =0;
for(int i=0;i<n;i++){
for(int j=i;j<n;j++){
csum =0;
for(int k=i;k<=j;k++){
csum+=arr[k];
}
if(fsum<csum)
fsum=csum;
l=i;
r=j;
}
}
for(int u=l;u<=r;u++){
cout<<arr[u]<<" ";
}
cout<<endl<<fsum;
}
//this is same code as in the video but its output is not correct whats wrong with this code?