#include <stdio.h>
#include <math.h>
double calculate_f(double x, double y)
//вместо if надо использовать оператор "?"
{
return (x > 0) ? (x + y) : ((x <= 0 && y < 0) ? fabs(y) : 5*x);
}
int main()
{
double x = 4.0, y = 2.0;
double f = calculate_f(x, y);
printf("f = %lf\n", f);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+Cgpkb3VibGUgY2FsY3VsYXRlX2YoZG91YmxlIHgsIGRvdWJsZSB5KQovL9Cy0LzQtdGB0YLQviBpZiDQvdCw0LTQviDQuNGB0L/QvtC70YzQt9C+0LLQsNGC0Ywg0L7Qv9C10YDQsNGC0L7RgCAiPyIKewogICByZXR1cm4gKHggPiAwKSA/ICh4ICsgeSkgOiAoKHggPD0gMCAmJiB5IDwgMCkgPyBmYWJzKHkpIDogNSp4KTsKfQoKaW50IG1haW4oKQp7CiAgIGRvdWJsZSB4ID0gNC4wLCB5ID0gMi4wOwogICBkb3VibGUgZiA9IGNhbGN1bGF0ZV9mKHgsIHkpOwogICBwcmludGYoImYgPSAlbGZcbiIsIGYpOwogICByZXR1cm4gMDsKfQo=