link to the problem: http://www.codechef.com/problems/HS08TEST
here is my code:
#include<stdio.h>
int main()
{
int x,k;
float y;
scanf("%d %f",&x,&y);
k=x%5;
if((k==0)&&((x-0.5)<y))
y=y-x-0.5;
printf("%.2f",y);
return 0;
}
Help please!!
link to the problem: http://www.codechef.com/problems/HS08TEST
here is my code:
#include<stdio.h>
int main()
{
int x,k;
float y;
scanf("%d %f",&x,&y);
k=x%5;
if((k==0)&&((x-0.5)<y))
y=y-x-0.5;
printf("%.2f",y);
return 0;
}
Help please!!
You get an incorrect out put for this case
120 120.00
And your output is
-0.50
When the actual output should have been
120.00
if( ( k == 0 ) && ( (x + 0.5 ) <= y ) )
^ ^
+ instead of - <=
You need ( x + 0.5 ) <= y