連続する配列の合計の最大値 (負の数を含む) を見つけようとしました。私が間違っている単一のケースを見つけるのを手伝ってください。
total=0 , sum= INT_MIN ;//initialisation of total and sum
for(int i=0;i<n;i++) //for array of n
{
total = arr[i] + total;
sum= max(total,sum);
if(total<0)
total=0;
}
cout<<sum;