how come runtime error?

#include<stdio.h>

int main()
{
int x,y,n,m;
float t,max=0.0,d,arr[10000],t1;
scanf("%d",&n);


for(x=0;x<n;x++)
{
scanf("%d%f",&m,&t);
for(y=0;y<m;y++)
scanf("%f",&arr[y]);

    if((arr[1]-arr[0])>t)
max=0.0;

if((arr[1]-arr[0])<t)
{
 if((arr[0]-(t-arr[1]-arr[0]))>0)
 {
max=(t-(arr[1]-arr[0]))/2;
     arr[0]=arr[0]-(t-(arr[1]-arr[0]))/2;
  arr[1]=arr[1]+max;

 }
else
{max=arr[0]-0.0;
 arr[0]=0.0;
    }
}
if(arr[1]-arr[0]<t)

{d=(t-(arr[1]-arr[0]));
if(d>max)
max=d;
arr[1]=t;
}

for(y=1;y<m-1;y++)
{
if((arr[y+1]-arr[y])<t)
{
d=t-(arr[y+1]-arr[y]);
        arr[y+1]=arr[y+1]+d;
        if(d>max)
        max=d;
    }
}


printf("%.4f\n",max);
}
return 1;
}

At a first glance at your code, I think you should write:

return 0;

on the last line, instead of return 1;

Good luck,

Bruno

1 Like

return 1 is the culprit

1 Like
//