why is the code below not taking sum in circular for,
i feel it is logically correct.
please check.
#include
#include
using namespace std;
int main()
{
int n;
cin>>n;
int brr[1000];
for(int i = 0; i<n; i++)
{
int New;
int arr[New+1000];
int cs=0;
int ms=0;
int p=0;
int n=1;
cin>>New;
for(int j=0; j<New; j++)
{
cin>>arr[j];
}
cs = arr[0];
while(n!=p )
{
cs = cs +arr[n];
if(cs<0)
{
cs = 0;
p = n+1;
}
n=n+1;
if(n=New-1)
{
cs =cs+arr[n];
n=0;
}
ms =max(cs,ms);
}
brr[i]=ms;
}
for(int i=0; i<n; i++)
{
cout<<brr[i]<<endl;
}
return 0;
}