HERE'S MY CODE, PLEASE HELP, WHAT'S WRONG? (WA#11)
#include <stdio.h>
int calculate(int a,int b,int c,int d);
int main()
{
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
printf("%d",calculate(a,b,c,d));
return 0;
}
int calculate(int a,int b,int c,int d)
{
if(a == c || a > c )
return a;
else if(a + b > c)
return c;
else if(((a+b) > (c-d))&& b < d)
return c;
else if( (a+b)==(c-d))
return (a+b);
else
while(1){
a+=b;
c-=d;
if( a>=c )
return a;
if( ((a+b) >= (c-d)) && ( b>=d))
return c;
}
}